Skip to content

Instantly share code, notes, and snippets.

@EvilWolf
Created May 31, 2016 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvilWolf/8f6a4b4eba5b1e57abbfa2ebbb833bac to your computer and use it in GitHub Desktop.
Save EvilWolf/8f6a4b4eba5b1e57abbfa2ebbb833bac to your computer and use it in GitHub Desktop.
aniview Entering Viewport
/**
* returns boolean representing whether element's top is coming into bottom of viewport
*
* @param HTMLDOMElement element the current element to check
*/
function EnteringViewport(element) {
var elementOffset = $(element).offset();
var elementTop = elementOffset.top + $(element).scrollTop();
var elementBottom = elementOffset.top + $(element).scrollTop() + $(element).height();
var viewportBottom = $(window).scrollTop() + $(window).height();
return (elementTop < (viewportBottom - settings.animateThreshold)) ? true : false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment