Skip to content

Commit

Permalink
refactor(swipe): optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Jan 5, 2024
1 parent e565454 commit 26e2da6
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/varlet-ui/src/swipe/Swipe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ export default defineComponent({
timer && clearTimeout(timer)
}
function setTrackTranslate(value: number) {
trackTranslate.value = value
}
async function handleTouchstart(event: TouchEvent) {
if (length.value <= 1 || !props.touchable) {
return
Expand All @@ -346,7 +342,7 @@ export default defineComponent({
}
preventDefault(event)
setTrackTranslate(trackTranslate.value + (vertical ? moveY.value : moveX.value))
trackTranslate.value += (vertical ? moveY.value : moveX.value)
dispatchSwipeItems()
}
Expand All @@ -373,7 +369,7 @@ export default defineComponent({
: getSwipeIndex()
lockDuration.value = false
setTrackTranslate(swipeIndex * -size.value)
trackTranslate.value = swipeIndex * -size.value
const prevIndex = index.value
index.value = swipeIndexToIndex(swipeIndex)
Expand Down

0 comments on commit 26e2da6

Please sign in to comment.