-
-
Save joehwang/1da4adf9ac7fd47acec5d5b3fda2a5ff to your computer and use it in GitHub Desktop.
轉換座標系
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 oMousePos(target, evt) { | |
| var rect = target.getBoundingClientRect(); | |
| console.log( Math.round(evt.clientX - rect.left)) | |
| return { | |
| x: Math.round(evt.clientX - rect.left), | |
| y: Math.round(evt.clientY - rect.top) | |
| }; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment