[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
2 changed files with 13 additions and 16 deletions
+9 -5
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;
}
}
};