Skip to content

Instantly share code, notes, and snippets.

@zorbash
Last active December 18, 2015 16:39
Show Gist options
  • Save zorbash/5813349 to your computer and use it in GitHub Desktop.
Save zorbash/5813349 to your computer and use it in GitHub Desktop.
Function to calculate an element's bounds
calculateBounds: ($element) ->
offset = $element.offset()
width = $element.width()
height = $element.height()
{
nw:
x: offset.left
y: offset.top
ne:
x: offset.left + width
y: offset.top
se:
x: offset.left + width
y: offset.left + height
sw:
x: offset.left
y: offset.top + height
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment