Skip to content

Instantly share code, notes, and snippets.

@jumplee
Created July 23, 2015 09:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save jumplee/c5d8ed299a1e7539fc4b to your computer and use it in GitHub Desktop.
Save jumplee/c5d8ed299a1e7539fc4b to your computer and use it in GitHub Desktop.
function isScrolledIntoView(elem)
{
var $elem = $(elem);
var $window = $(window);
var docViewTop = $window.scrollTop();
var docViewBottom = docViewTop + $window.height();
var elemTop = $elem.offset().top;
var elemBottom = elemTop + $elem.height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment