Created
August 8, 2018 16:33
-
-
Save digamber89/f3f5679538388ba44796c84b8ef5570c to your computer and use it in GitHub Desktop.
Is in Viewport
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
$.fn.isInViewport = function () { | |
var elementTop = $(this).offset().top; | |
var elementBottom = elementTop + $(this).outerHeight(); | |
var viewportTop = $(window).scrollTop(); | |
var viewportBottom = viewportTop + $(window).height(); | |
return elementBottom > viewportTop && elementTop < viewportBottom; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment