Skip to content

Instantly share code, notes, and snippets.

@layerssss
Created January 24, 2013 11:01
Show Gist options
  • Save layerssss/4620055 to your computer and use it in GitHub Desktop.
Save layerssss/4620055 to your computer and use it in GitHub Desktop.
var x;
var y;
if (e.pageX || e.pageY) {
x = e.pageX;
y = e.pageY;
}
else {
x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
y -= $(this).offset().top;
x -= $(this).offset().left;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment