Skip to content

Instantly share code, notes, and snippets.

@rf-
Forked from anonymous/gist:954770
Created May 4, 2011 05:13
Show Gist options
  • Save rf-/954788 to your computer and use it in GitHub Desktop.
Save rf-/954788 to your computer and use it in GitHub Desktop.
coffeescript global offset
# note that this is gross
findPos = (obj) ->
values = while (obj = obj.offsetParent)
[obj.offsetLeft, obj.offsetTop]
_.reduce(values, (sums, pair) ->
left: sums.left + pair[0]
right: sums.right + pair[1]
left: 0, top: 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment