Skip to content

Instantly share code, notes, and snippets.

@oxUnd
Created March 4, 2014 09:04
Show Gist options
  • Save oxUnd/606dface96dd7292ecbc to your computer and use it in GitHub Desktop.
Save oxUnd/606dface96dd7292ecbc to your computer and use it in GitHub Desktop.
function getOffset( el ) {
var _x = 0;
var _y = 0;
while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
_x += el.offsetLeft - el.scrollLeft;
_y += el.offsetTop - el.scrollTop;
el = el.offsetParent;
}
return { top: _y, left: _x };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment