Last active
April 5, 2016 16:37
-
-
Save edgarberm/8d85340e8e338be2a746cf8e79d9b378 to your computer and use it in GitHub Desktop.
Check if element is into view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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