Skip to content

Instantly share code, notes, and snippets.

@jashkenas
Forked from cantino/gist:718228
Created November 27, 2010 20:26
Show Gist options
  • Save jashkenas/718243 to your computer and use it in GitHub Desktop.
Save jashkenas/718243 to your computer and use it in GitHub Desktop.
class Utilities
@findPos: (obj) ->
obj = obj.get(0) if obj.html?
left = top = 0
measure = ->
left += obj.offsetLeft
top += obj.offsetTop
measure()
measure() while obj = obj.offsetParent
{ x: left, y: top }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment