mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-21 13:59:15 +08:00
fix(Tab): swipe multi index with double refers (#4539)
* fix(Tab): swipe multi index with double refers * fix(Tab): adjust swiping
This commit is contained in:
parent
04ddd811b2
commit
7cbf287438
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user