From 7cbf287438806c2b043fb662bd0a12ffb94e6171 Mon Sep 17 00:00:00 2001 From: nemo-shen Date: Thu, 30 Sep 2021 10:22:50 +0800 Subject: [PATCH] fix(Tab): swipe multi index with double refers (#4539) * fix(Tab): swipe multi index with double refers * fix(Tab): adjust swiping --- packages/tabs/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/tabs/index.ts b/packages/tabs/index.ts index 54215951..974b686f 100644 --- a/packages/tabs/index.ts +++ b/packages/tabs/index.ts @@ -94,7 +94,7 @@ VantComponent({ scrollLeft: 0, scrollable: false, currentIndex: 0, - container: (null as unknown) as () => WechatMiniprogram.NodesRef, + container: null as unknown as () => WechatMiniprogram.NodesRef, skipTransition: true, scrollWithAnimation: false, lineOffsetLeft: 0, @@ -102,6 +102,7 @@ VantComponent({ mounted() { requestAnimationFrame(() => { + this.swiping = true; this.setData({ container: () => this.createSelectorQuery().select('.van-tabs'), }); @@ -238,6 +239,7 @@ VantComponent({ (rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8); this.setData({ lineOffsetLeft }); + this.swiping = true; if (skipTransition) { nextTick(() => { @@ -287,14 +289,14 @@ VantComponent({ }, onTouchMove(event: WechatMiniprogram.TouchEvent) { - if (!this.data.swipeable) return; + if (!this.data.swipeable || !this.swiping) return; this.touchMove(event); }, // watch swipe touch end onTouchEnd() { - if (!this.data.swipeable) return; + if (!this.data.swipeable || !this.swiping) return; const { direction, deltaX, offsetX } = this; const minSwipeDistance = 50; @@ -305,6 +307,8 @@ VantComponent({ this.setCurrentIndex(index); } } + + this.swiping = false; }, getAvaiableTab(direction: number) {