Created
February 4, 2012 10:16
-
-
Save Ninir/1736921 to your computer and use it in GitHub Desktop.
jQuery get elements currently in view
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 isScrolledIntoView(elem) | |
{ | |
var docViewTop = $(window).scrollTop(); | |
var docViewBottom = docViewTop + $(window).height(); | |
var elemTop = $(elem).offset().top; | |
var elemBottom = elemTop + $(elem).height(); | |
return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment