Skip to content

Instantly share code, notes, and snippets.

@mamboer
Created May 8, 2015 15:44
Show Gist options
  • Save mamboer/1dfbff7ec329bd3778ff to your computer and use it in GitHub Desktop.
Save mamboer/1dfbff7ec329bd3778ff to your computer and use it in GitHub Desktop.
(function ($){
var check=false, isRelative=true;
$.elementFromPoint = function(x,y)
{
if(!document.elementFromPoint) return null;
if(!check)
{
var sl;
if((sl = $(document).scrollTop()) >0)
{
isRelative = (document.elementFromPoint(0, sl + $(window).height() -1) == null);
}
else if((sl = $(document).scrollLeft()) >0)
{
isRelative = (document.elementFromPoint(sl + $(window).width() -1, 0) == null);
}
check = (sl>0);
}
if(!isRelative)
{
x += $(document).scrollLeft();
y += $(document).scrollTop();
}
return document.elementFromPoint(x,y);
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment