Skip to content

Instantly share code, notes, and snippets.

@lavarini
Last active December 26, 2015 13:29
Show Gist options
  • Save lavarini/7159032 to your computer and use it in GitHub Desktop.
Save lavarini/7159032 to your computer and use it in GitHub Desktop.
Browser scroll - do something
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