Created
January 8, 2019 01:36
-
-
Save mohsenheydari/05193dd419cd2f9a352def31fdaed64e to your computer and use it in GitHub Desktop.
Transforms document cursor position to position relative to canvas
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
getRelativeCursorPosition(event){ | |
var rect = this.canvas.getBoundingClientRect(); | |
return { | |
x: event.clientX - rect.left, | |
y: event.clientY - rect.top | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment