Created
February 21, 2021 03:42
-
-
Save joehonton/9b6dbe6d6b1617c0281fc61832f381bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FingerPointer { | |
constructor(event) { | |
this.pointerId = event.pointerId; | |
this.pointerType = event.pointerType; | |
this.epsilonX = event.width; | |
this.epsilonY = event.height; | |
this.initial = { | |
x: event.offsetX, | |
y: event.offsetY, | |
t: Date.now() | |
}; | |
this.latest = { | |
x: event.offsetX, | |
y: event.offsetY, | |
t: Date.now() | |
}; | |
this.deltaT = 0; | |
this.deltaX = 0; | |
this.deltaY = 0; | |
this.deltaXY = 0; | |
this.directionX = ''; | |
this.directionY = ''; | |
if (event.buttons == undefined) { | |
this.leftButtonDown = false; | |
this.wheelButtonDown = false; | |
this.rightButtonDown = false; | |
} | |
else { | |
this.leftButtonDown = | |
(event.buttons & 0b0001) ? true : false; | |
this.rightButtonDown = | |
(event.buttons & 0b0010) ? true : false; | |
this.wheelButtonDown = | |
(event.buttons & 0b0100) ? true : false; | |
} | |
this.ctrlKey = !!event.ctrlKey; | |
this.altKey = !!event.altKey; | |
this.shiftKey = !!event.shiftKey; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment