Created
June 7, 2018 14:04
-
-
Save daydarkln/95c4952727763de62be83cc0d6e7a966 to your computer and use it in GitHub Desktop.
This one return true if element is locate in viewport cooordinates
This file contains 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
var elementInViewport = function(elem) { | |
var rect = elem.getBoundingClientRect(); | |
return ( | |
rect.top >= 0 && | |
rect.left >= 0 && | |
rect.top <= (window.innerHeight || document.documentElement.clientHeight) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment