Skip to content

Instantly share code, notes, and snippets.

@dkdndes
Created April 17, 2019 21:40
Show Gist options
  • Save dkdndes/ed289eaa4651efe887f545dd4cf6aff4 to your computer and use it in GitHub Desktop.
Save dkdndes/ed289eaa4651efe887f545dd4cf6aff4 to your computer and use it in GitHub Desktop.
function findPosX(obj) {
var curleft = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
obj = obj.offsetParent;
}
// IE offsetParent does not include the top-level
if (isIE && obj.parentElement){
curleft += obj.offsetLeft - obj.scrollLeft;
}
}
else if (obj.x) {
curleft += obj.x;
}
return curleft;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment