You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
889 B
28 lines
889 B
export const touch = Behavior({
|
|
methods: {
|
|
touchStart(event) {
|
|
const touch = event.touches[0];
|
|
this.direction = '';
|
|
this.deltaX = 0;
|
|
this.deltaY = 0;
|
|
this.offsetX = 0;
|
|
this.offsetY = 0;
|
|
this.startX = touch.clientX;
|
|
this.startY = touch.clientY;
|
|
},
|
|
touchMove(event) {
|
|
const touch = event.touches[0];
|
|
this.deltaX = touch.clientX - this.startX;
|
|
this.deltaY = touch.clientY - this.startY;
|
|
this.offsetX = Math.abs(this.deltaX);
|
|
this.offsetY = Math.abs(this.deltaY);
|
|
this.direction =
|
|
this.offsetX > this.offsetY
|
|
? 'horizontal'
|
|
: this.offsetX < this.offsetY
|
|
? 'vertical'
|
|
: '';
|
|
}
|
|
}
|
|
});
|