Joined October 2013
·
Posted to
jQuery Events for Start/Stop Scrolling
over 1 year
ago
// Seriously?
var TO = false;
var scroll_static = true;
$(window).scroll(function(){
if( scroll_static ){
console.log('start scrolling');
scroll_static = false;
}
if(TO !== false){ clearTimeout(TO); }
TO = setTimeout(myfunction, 200);
});
function myfunction(){
scroll_static = true;
console.log('stopped scrolling');
}
</code></pre>
200 is trigger offset time.
Well done. But ya, that's in just about every js library. Although handy if working with vanilla javascript.