Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunoocasali/aacfa69bb0e9c8a8bcbbb79bc192bd2c to your computer and use it in GitHub Desktop.
Save brunoocasali/aacfa69bb0e9c8a8bcbbb79bc192bd2c to your computer and use it in GitHub Desktop.
@checkScreenFor: (el) ->
view =
top: window.scrollY
left: window.scrollX
right: window.scrollX + document.documentElement.clientWidth
bottom: window.scrollY + document.documentElement.clientHeight
bounds = el.getBoundingClientRect()
bounds =
top: bounds.top + document.body.scrollTop
left: bounds.left + document.body.scrollLeft
right: bounds.left + el.offsetWidth
bottom: bounds.top + el.outerHeight
!(view.right < bounds.left or view.left > bounds.right or view.bottom < bounds.top or view.top > bounds.bottom)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment