-
-
Save dexit/bbc41a3c2f7247dce6a0fa61d0b9ba4b to your computer and use it in GitHub Desktop.
I spent way too much time digging the correct properties. For future reference.
This file contains hidden or 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
| function onMouseMove(event, initialX: number, initialY: number) { | |
| const { clientX, clientY, movementX, movementY } = event | |
| const moving = { | |
| left: movementX < 0 | |
| right: movementX > 0 | |
| up: movementY < 0 | |
| down: movementY > 0 | |
| } | |
| // Use these to determine how much the cursor has moved from initialX & Y | |
| const xOffset = clientX - initialX // Negative value means left, positive means right | |
| const yOffset = clientY - initialY // Positive value means down, negative means up | |
| return { | |
| xOffset, yOffset, | |
| moving | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment