Last active
December 24, 2015 17:09
-
-
Save gcpantazis/6833091 to your computer and use it in GitHub Desktop.
Element scrolled into view, with a 100 pixel threshold.
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
var checkActive = function(el) { | |
var self = this, | |
elRect = el.getBoundingClientRect(), | |
winRect = document.documentElement.getBoundingClientRect(), | |
isNearBottom = winRect.bottom - elRect.bottom < 100 && $(document).height() - ($(window).scrollTop() + $(window).height()) < 100; | |
if (elRect.top < 100 && elRect.top > 0 || isNearBottom) { | |
// Element is scrolled into view. | |
} | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment