touch.d.ts.map 1.1 KB

1
  1. {"version":3,"sources":["../src/behaviors/touch.ts"],"names":[],"mappings":";AAWA,wBAwBG","file":"touch.d.ts","sourcesContent":["const MinDistance = 10;\nconst getDirection = (x: number, y: number) => {\n if (x > y && x > MinDistance) {\n return 'horizontal';\n }\n if (y > x && y > MinDistance) {\n return 'vertical';\n }\n return '';\n};\n\nexport default Behavior({\n methods: {\n resetTouchStatus() {\n this.direction = '';\n this.deltaX = 0;\n this.deltaY = 0;\n this.offsetX = 0;\n this.offsetY = 0;\n },\n touchStart(event: any) {\n this.resetTouchStatus();\n const [touch] = event.touches;\n this.startX = touch.clientX;\n this.startY = touch.clientY;\n },\n touchMove(event: any) {\n const [touch] = event.touches;\n this.deltaX = touch.clientX - this.startX;\n this.deltaY = touch.clientY - this.startY;\n this.offsetX = Math.abs(this.deltaX);\n this.offsetY = Math.abs(this.deltaY);\n this.direction = this.direction || getDirection(this.offsetX, this.offsetY);\n },\n },\n});\n"]}