Last active
December 26, 2015 13:29
-
-
Save lavarini/7159032 to your computer and use it in GitHub Desktop.
Browser scroll - do something
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 scrolled, $w = $(window); | |
$w.on('scroll', function() { | |
scrolled = true; | |
}); | |
window.scroll_timeout = setInterval(doSomething, 100); | |
function doSomething() { | |
if (!scrolled) { | |
return; | |
} | |
scrolled = false; | |
console.log($w.scrollTop()); | |
if ($w.scrollTop() > 250) { | |
console.log('CHEGOU!!!'); | |
$w.off('scroll'); | |
clearTimeout(window.scroll_timeout); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment