javascript - Turn off firefox's smooth scrolling? -
firefox's new smooth scrolling feature causes scroll callback trigger @ each step in animation.
demo in ff , chrome see difference
is there way have
- only fires 1 event when page has finished scrolling
- make page scroll abruptly in chrome
try this:
function throttle( fn, timeout ) { var tid = 0; return function() { cleartimeout( tid ); var args = [].slice.call( arguments ), ctx = this; tid = settimeout( function() { fn.apply( ctx, args ); }, timeout ); }; } $(window).on("scroll", throttle( function() { $('div').eq(0).append('scroll happened'); }, 100));
it fire scroll once no scroll has happened in 100 milliseconds.
Comments
Post a Comment