Skip to content

Instantly share code, notes, and snippets.

@Ninir
Created February 4, 2012 10:16
Show Gist options
  • Save Ninir/1736921 to your computer and use it in GitHub Desktop.
Save Ninir/1736921 to your computer and use it in GitHub Desktop.
jQuery get elements currently in view
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