[bugfix] Swipe: wrong position (#1723)

This commit is contained in:
neverland 2018-08-30 16:55:28 +08:00 committed by GitHub
parent 56cc2ce837
commit dee56c75b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 16 deletions

View File

@ -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;
}
}
};

View File

@ -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(() => {