Skip to content

Instantly share code, notes, and snippets.

@fiveminuteargument
Created April 2, 2013 09:49
Show Gist options
  • Save fiveminuteargument/5291133 to your computer and use it in GitHub Desktop.
Save fiveminuteargument/5291133 to your computer and use it in GitHub Desktop.
getLayout: function(el) {
var props = { width: 'Width', height: 'Height', left: 'Left', top: 'Top' };
for (var p in props)
props[p] = el['offset' + props[p]];
while (el = el.offsetParent) {
props.left += el.offsetLeft;
props.top += el.offsetTop;
}
for (var p in props)
props[p] += 'px';
return props;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment