Last active
August 29, 2015 14:02
-
-
Save billyxs/982ab6fb5a0531147dc0 to your computer and use it in GitHub Desktop.
Get Mouse Event Position
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
function(e) { | |
if(!e) var e = window.event; | |
var posx = 0; | |
var posy = 0; | |
if (e.pageX || e.pageY) { | |
posx = e.pageX; | |
posy = e.pageY; | |
} | |
else if (e.clientX || e.clientY) { | |
posx = e.clientX + document.body.scrollLeft | |
+ document.documentElement.scrollLeft; | |
posy = e.clientY + document.body.scrollTop | |
+ document.documentElement.scrollTop; | |
} | |
return {x: posx, y: posy}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment