Created
August 27, 2019 09:18
-
-
Save rowan-m/a9fe3ca2976e350dbe188494d0ba2c0a 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
_onPointerdown(e) { | |
e.preventDefault(); | |
this._touchX = e.clientX; | |
this._touchY = e.clientY; | |
// ✂️ Chop out existing code, extract into new method | |
this._rotationStart(); | |
this.setPointerCapture(e.pointerId); | |
this.addEventListener('pointermove', this._onPointermove); | |
this.addEventListener('pointerup', this._onPointerup); | |
this.addEventListener('pointercancel', this._onPointerup); | |
} | |
_onPointermove(e) { | |
e.preventDefault(); | |
this._touchX = e.clientX; | |
this._touchY = e.clientY; | |
// ✂️ Cut and paste again | |
this._rotationChange(); | |
} | |
_onPointerup(e) { | |
e.preventDefault(); | |
// ✂️ One last time! | |
this._rotationEnd(); | |
this.releasePointerCapture(e.pointerId); | |
this.removeEventListener('pointermove', this._onPointermove); | |
this.removeEventListener('pointerup', this._onPointerup); | |
this.removeEventListener('pointercancel', this._onPointerup); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment