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,
|
scrollLeft: 0,
|
||||||
scrollable: false,
|
scrollable: false,
|
||||||
currentIndex: 0,
|
currentIndex: 0,
|
||||||
container: (null as unknown) as () => WechatMiniprogram.NodesRef,
|
container: null as unknown as () => WechatMiniprogram.NodesRef,
|
||||||
skipTransition: true,
|
skipTransition: true,
|
||||||
scrollWithAnimation: false,
|
scrollWithAnimation: false,
|
||||||
lineOffsetLeft: 0,
|
lineOffsetLeft: 0,
|
||||||
@ -102,6 +102,7 @@ VantComponent({
|
|||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
|
this.swiping = true;
|
||||||
this.setData({
|
this.setData({
|
||||||
container: () => this.createSelectorQuery().select('.van-tabs'),
|
container: () => this.createSelectorQuery().select('.van-tabs'),
|
||||||
});
|
});
|
||||||
@ -238,6 +239,7 @@ VantComponent({
|
|||||||
(rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8);
|
(rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8);
|
||||||
|
|
||||||
this.setData({ lineOffsetLeft });
|
this.setData({ lineOffsetLeft });
|
||||||
|
this.swiping = true;
|
||||||
|
|
||||||
if (skipTransition) {
|
if (skipTransition) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@ -287,14 +289,14 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onTouchMove(event: WechatMiniprogram.TouchEvent) {
|
onTouchMove(event: WechatMiniprogram.TouchEvent) {
|
||||||
if (!this.data.swipeable) return;
|
if (!this.data.swipeable || !this.swiping) return;
|
||||||
|
|
||||||
this.touchMove(event);
|
this.touchMove(event);
|
||||||
},
|
},
|
||||||
|
|
||||||
// watch swipe touch end
|
// watch swipe touch end
|
||||||
onTouchEnd() {
|
onTouchEnd() {
|
||||||
if (!this.data.swipeable) return;
|
if (!this.data.swipeable || !this.swiping) return;
|
||||||
|
|
||||||
const { direction, deltaX, offsetX } = this;
|
const { direction, deltaX, offsetX } = this;
|
||||||
const minSwipeDistance = 50;
|
const minSwipeDistance = 50;
|
||||||
@ -305,6 +307,8 @@ VantComponent({
|
|||||||
this.setCurrentIndex(index);
|
this.setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.swiping = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
getAvaiableTab(direction: number) {
|
getAvaiableTab(direction: number) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user