Skip to content

Commit

Permalink
fix: 🐛 修复 SwipeAction 组件在H5端导致页面无法上下滚动的问题
Browse files Browse the repository at this point in the history
Closes: #149
  • Loading branch information
xuqingkai committed Dec 28, 2023
1 parent c88c84e commit 1f68ce1
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
<view
:class="`wd-swipe-action ${customClass}`"
@click.stop="onClick()"
@touchmove="stopPropagation ? nothing : ''"
@touchstart="startDrag"
@touchmove.prevent="onDrag"
@touchmove="onDrag"
@touchend="endDrag"
@touchcancel="endDrag"
>
Expand Down Expand Up @@ -58,7 +57,6 @@ const props = withDefaults(defineProps<Props>(), {
const queue = inject<Queue | null>(queueKey, null)
const wrapperStyle = ref<string>('')
const stopPropagation = ref<boolean>(false)
// 滑动开始时,wrapper的偏移量
const originOffset = ref<number>(0)
Expand Down Expand Up @@ -131,8 +129,7 @@ function changeState(value: string, old?: string) {
}
})
}
/** 防穿透函数的占位符 **/
function nothing() {}
/**
* @description 获取左/右操作按钮的宽度
* @return {Promise<[Number, Number]>} 左宽度、右宽度
Expand Down Expand Up @@ -202,12 +199,11 @@ function onDrag(event) {
if (props.disabled) return
touch.touchMove(event)
if (touch.direction.value === 'vertical') {
stopPropagation.value = false
return
} else {
stopPropagation.value = true
event.preventDefault()
event.stopPropagation()
}
touching.value = true
Expand Down Expand Up @@ -238,7 +234,6 @@ function endDrag() {
if (props.disabled) return
// 滑出"操作按钮"的阈值
const THRESHOLD = 0.3
stopPropagation.value = false
touching.value = false
getWidths().then(([leftWidth, rightWidth]) => {
Expand Down

0 comments on commit 1f68ce1

Please sign in to comment.