Skip to content

Instantly share code, notes, and snippets.

@xxjinwei
Created December 17, 2013 03:29
Show Gist options
  • Save xxjinwei/7999609 to your computer and use it in GitHub Desktop.
Save xxjinwei/7999609 to your computer and use it in GitHub Desktop.
get offset
function getOffset (ele) {
var box = ele.getBoundingClientRect();
return {
top: box.top + (window.pageYOffset || document.documentElement.scrollTop) - (document.documentElement.clientTop || 0),
left: box.left + (window.pageXOffset || document.documentElement.scrollLeft) - (document.documentElement.clientLeft || 0)
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment