Last active
May 24, 2017 22:17
-
-
Save halfempty/aca5a5a78063713dddb742b6e8228048 to your computer and use it in GitHub Desktop.
Notes for Will
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
// Checking visibility | |
jQuery.fn.isScrolledIntoView = function () { | |
var thisOffset = $(this).offset().top; | |
var windowHeight = $(window).height(); | |
var heightToThis = thisOffset - windowHeight; | |
var scrollPosition = $(window).scrollTop(); | |
if ( (scrollPosition >= heightToThis ) ) { | |
return true; | |
} | |
} | |
// Timer on scroll | |
$(window).scroll(function(){ | |
// Resize actions are in handleScroll() | |
if (scrollTimer) { | |
clearTimeout(scrollTimer); // clear any previous pending timer | |
} | |
scrollTimer = setTimeout(handleScroll, 1); // set new timer | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment