Created
May 31, 2016 12:34
-
-
Save EvilWolf/8f6a4b4eba5b1e57abbfa2ebbb833bac to your computer and use it in GitHub Desktop.
aniview Entering Viewport
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
/** | |
* 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