Skip to content

Commit

Permalink
fix: preventDefault
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu committed Dec 6, 2023
1 parent 884b625 commit b011966
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 8 additions & 10 deletions src/packages/__VUE/range/index.taro.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
:aria-valuenow="curValue(index)"
:aria-valuemax="+max"
aria-orientation="horizontal"
@touchstart.stop.prevent="
@touchstart="
(e) => {
if (typeof index === 'number') {
// 实时更新当前拖动的按钮索引
Expand All @@ -35,9 +35,9 @@
onTouchStart(e);
}
"
@touchmove.stop.prevent="onTouchMove"
@touchend.stop.prevent="onTouchEnd"
@touchcancel.stop.prevent="onTouchEnd"
@touchmove="onTouchMove"
@touchend="onTouchEnd"
@touchcancel="onTouchEnd"
@click="(e) => e.stopPropagation()"
>
<slot v-if="$slots.button" name="button"></slot>
Expand Down Expand Up @@ -84,6 +84,7 @@ import { createComponent } from '@/packages/utils/create';
import { useTouch } from '@/packages/utils/useTouch';
import { useTaroRect } from '@/packages/utils/useTaroRect';
import { SliderValue } from './type';
import { preventDefault } from '@/packages/utils/util';
const { componentName, create } = createComponent('range');
export default create({
Expand Down Expand Up @@ -353,8 +354,7 @@ export default create({
}
dragStatus.value = 'start';
event.stopPropagation();
if (event.cancelable) event.preventDefault();
preventDefault(event, true);
};
// 初始化 range 宽高
Expand All @@ -372,8 +372,7 @@ export default create({
if (props.disabled) {
return;
}
event.stopPropagation();
if (event.cancelable) event.preventDefault();
preventDefault(event, true);
if (dragStatus.value === 'start') {
emit('dragStart');
}
Expand Down Expand Up @@ -405,8 +404,7 @@ export default create({
emit('dragEnd');
}
dragStatus.value = '';
event.stopPropagation();
if (event.cancelable) event.preventDefault();
preventDefault(event, true);
};
const curValue = (idx?: number): number => {
const value =
Expand Down
2 changes: 0 additions & 2 deletions src/packages/__VUE/range/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ export default create({
currentValue = startValue + diff;
}
updateValue(currentValue);
event.stopPropagation();
if (event.cancelable) event.preventDefault();
};
const onTouchEnd = () => {
Expand Down

0 comments on commit b011966

Please sign in to comment.