mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
24 lines
855 B
JavaScript
24 lines
855 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.touch = Behavior({
|
|
methods: {
|
|
touchStart: function (event) {
|
|
this.direction = '';
|
|
this.deltaX = 0;
|
|
this.deltaY = 0;
|
|
this.offsetX = 0;
|
|
this.offsetY = 0;
|
|
this.startX = event.touches[0].clientX;
|
|
this.startY = event.touches[0].clientY;
|
|
},
|
|
touchMove: function (event) {
|
|
var 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' : '';
|
|
}
|
|
}
|
|
});
|