Created
May 8, 2015 15:44
-
-
Save mamboer/1dfbff7ec329bd3778ff to your computer and use it in GitHub Desktop.
jquery elementFromPoint (http://www.zehnet.de/2010/11/19/document-elementfrompoint-a-jquery-solution/)
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 ($){ | |
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