Skip to content

Instantly share code, notes, and snippets.

@BKeanu1989
Created September 29, 2017 18:58
Show Gist options
  • Save BKeanu1989/b2b639d797371ede78623c1335baaf74 to your computer and use it in GitHub Desktop.
Save BKeanu1989/b2b639d797371ede78623c1335baaf74 to your computer and use it in GitHub Desktop.
cumulativeOffset
var cumulativeOffset = function(element) {
var top = 0, left = 0;
do {
top += element.offsetTop || 0;
left += element.offsetLeft || 0;
element = element.offsetParent;
} while(element);
return {
top: top,
left: left
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment