From 26e2da66b654b969e4acbf9e68758ae39b2f421a Mon Sep 17 00:00:00 2001 From: haoziqaq <357229046@qq.com> Date: Fri, 5 Jan 2024 22:49:20 +0800 Subject: [PATCH] refactor(swipe): optimize code --- packages/varlet-ui/src/swipe/Swipe.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/varlet-ui/src/swipe/Swipe.vue b/packages/varlet-ui/src/swipe/Swipe.vue index 3d887c74cb5..6ae19ad4ceb 100644 --- a/packages/varlet-ui/src/swipe/Swipe.vue +++ b/packages/varlet-ui/src/swipe/Swipe.vue @@ -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 @@ -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() } @@ -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)