Started using TSLint

This commit is contained in:
2019-11-17 18:09:39 +09:00
parent 5394928ea9
commit 62d63740bb
7 changed files with 134 additions and 125 deletions

View File

@ -1,13 +1,12 @@
export default class TouchController {
x: number
y: number
public leftSwipe: Function
public rightSwipe: Function
public upSwipe: Function
public downSwipe: Function
threshold: number
leftSwipe: Function
rightSwipe: Function
upSwipe: Function
downSwipe: Function
private x: number
private y: number
private threshold: number
constructor() {
document.addEventListener("touchstart", evt => this.handleTouchStart(evt), false)
@ -19,21 +18,21 @@ export default class TouchController {
this.y = -1
}
handleTouchStart(evt) {
private handleTouchStart(evt) {
this.x = evt.touches[0].clientX
this.y = evt.touches[0].clientY
}
handleTouchMove(evt) {
private handleTouchMove(evt) {
if(this.x === -1 || this.y === -1) {
return
}
let xUp = evt.touches[0].clientX
let yUp = evt.touches[0].clientY
const xUp = evt.touches[0].clientX
const yUp = evt.touches[0].clientY
let xDiff = this.x - xUp
let yDiff = this.y - yUp
const xDiff = this.x - xUp
const yDiff = this.y - yUp
if(Math.abs(xDiff) > Math.abs(yDiff)) {
if(xDiff > this.threshold) {
@ -52,4 +51,4 @@ export default class TouchController {
this.x = -1
this.y = -1
}
}
}