Created
March 14, 2019 14:47
-
-
Save anacampesan/ea34776793b7db87e5fc74b8e57588a6 to your computer and use it in GitHub Desktop.
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
function elementIsVisible(el) { | |
var docViewTop = $(window).scrollTop(); | |
var docViewBottom = docViewTop + $(window).height(); | |
var elTop = $(el).offset().top; | |
var elBottom = elTop + $(el).height(); | |
return ((elBottom - $(el).height() <= docViewBottom) | |
&& (elTop + $(el).height() >= docViewTop)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment