Skip to content

Instantly share code, notes, and snippets.

@mkuklis
Created September 20, 2012 17:38
Show Gist options
  • Save mkuklis/3757282 to your computer and use it in GitHub Desktop.
Save mkuklis/3757282 to your computer and use it in GitHub Desktop.
elementFromPoint
(function ($) {
$.elementFromPoint = function (x, y) {
var moved = false;
var yo = window.pageYOffset;
var xo = window.pageXOffset;
var w = window.innerWidth;
var h = window.innerHeight;
if (yo > 0) {
moved = (doc.elementFromPoint(0, yo + h - 1) === null);
} else if (xo > 0) {
moved = (doc.elementFromPoint(xo + w - 1, 0) === null);
}
return (moved) ?
doc.elementFromPoint(x - xo, y - yo) :
doc.elementFromPoint(x, y);
}
})(Zepto);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment