mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] Swipe: wrong position (#1723)
This commit is contained in:
parent
56cc2ce837
commit
dee56c75b7
@ -1,11 +1,7 @@
|
||||
export default {
|
||||
methods: {
|
||||
touchStart(event) {
|
||||
this.direction = '';
|
||||
this.deltaX = 0;
|
||||
this.deltaY = 0;
|
||||
this.offsetX = 0;
|
||||
this.offsetY = 0;
|
||||
this.resetTouchStatus();
|
||||
this.startX = event.touches[0].clientX;
|
||||
this.startY = event.touches[0].clientY;
|
||||
},
|
||||
@ -17,6 +13,14 @@ export default {
|
||||
this.offsetX = Math.abs(this.deltaX);
|
||||
this.offsetY = Math.abs(this.deltaY);
|
||||
this.direction = this.offsetX > this.offsetY ? 'horizontal' : this.offsetX < this.offsetY ? 'vertical' : '';
|
||||
},
|
||||
|
||||
resetTouchStatus() {
|
||||
this.direction = '';
|
||||
this.deltaX = 0;
|
||||
this.deltaY = 0;
|
||||
this.offsetX = 0;
|
||||
this.offsetY = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -211,21 +211,13 @@ export default create({
|
||||
return;
|
||||
}
|
||||
|
||||
swipes[0].offset = (atLast && (delta < 0 || move > 0)) ? trackSize : 0;
|
||||
swipes[count - 1].offset = (atFirst && (delta > 0 || move < 0)) ? -trackSize : 0;
|
||||
|
||||
if (move && active + move >= -1 && active + move <= count) {
|
||||
if (active === -1) {
|
||||
swipes[count - 1].offset = 0;
|
||||
}
|
||||
swipes[0].offset = atLast && move > 0 ? trackSize : 0;
|
||||
|
||||
this.active += move;
|
||||
}
|
||||
|
||||
if (atFirst) {
|
||||
swipes[count - 1].offset = delta > 0 || move < 0 ? -trackSize : 0;
|
||||
} else if (atLast) {
|
||||
swipes[0].offset = delta < 0 || move > 0 ? trackSize : 0;
|
||||
}
|
||||
|
||||
this.offset = offset - this.active * this.size;
|
||||
},
|
||||
|
||||
@ -258,6 +250,7 @@ export default create({
|
||||
this.clear();
|
||||
this.timer = setTimeout(() => {
|
||||
this.swiping = true;
|
||||
this.resetTouchStatus();
|
||||
this.correctPosition();
|
||||
|
||||
setTimeout(() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user