Created
August 27, 2019 09:18
-
-
Save rowan-m/af8604d705d6a15e6a7de7a40d946b55 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
// _onPointermove(e) | |
this._touchX = e.clientX; | |
this._touchY = e.clientY; | |
this._angle = | |
// initial rotation of the element | |
this._initialAngle | |
// subtract the starting touch angle | |
- this._initialTouchAngle | |
// add the current touch angle | |
+ Math.atan2(this._touchY - this._centerY, this._touchX - this._centerX); | |
// Normalise value back into a 2π range | |
this._angle = (this._angle + TWO_PI) % TWO_PI; | |
// Done, update the value! | |
this.value = this._angle; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment