Skip to content

Instantly share code, notes, and snippets.

@hsnaydd
Created April 20, 2015 12:47
Show Gist options
  • Save hsnaydd/c9d92ae93bd3b2845dea to your computer and use it in GitHub Desktop.
Save hsnaydd/c9d92ae93bd3b2845dea to your computer and use it in GitHub Desktop.
Javascript offset() function
getOffsetSum = (elem)->
top = 0
left = 0
while ( elem )
top = top + parseInt( elem.offsetTop )
left = left + parseInt( elem.offsetLeft )
elem = elem.offsetParent
return { top: top, left: left }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment