Created
September 10, 2014 14:23
-
-
Save genoma/d075e6e36580e883880c to your computer and use it in GitHub Desktop.
Element is on view, return false, true
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
isScrolledIntoView = (elem) -> | |
docViewTop = $(window).scrollTop() | |
docViewBottom = docViewTop + $(window).height() | |
elemTop = $(elem).offset().top | |
elemBottom = elemTop + $(elem).height() | |
(elemBottom - 200 < docViewBottom) and (elemBottom + $(elem).height() > docViewBottom ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment