Skip to content

Instantly share code, notes, and snippets.

@edgarberm
Last active April 5, 2016 16:37
Show Gist options
  • Save edgarberm/8d85340e8e338be2a746cf8e79d9b378 to your computer and use it in GitHub Desktop.
Save edgarberm/8d85340e8e338be2a746cf8e79d9b378 to your computer and use it in GitHub Desktop.
Check if element is into view
function isScrolledIntoView (el) {
var elemTop = el.getBoundingClientRect().top;
var elemBottom = el.getBoundingClientRect().bottom;
var isVisible = (elemTop >= 0) && (elemBottom <= window.innerHeight);
return isVisible;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment