Firefox 的新平滑滚动功能会在动画的每一步触发滚动回调。
DEMO in FF and Chrome to see the difference
有什么办法可以让它
- 仅在页面完成滚动时触发一个事件
- 使页面像 Chrome 中那样突然滚动
最佳答案
试试这个:
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));
只有在 100 毫秒内没有发生滚动时才会触发滚动。
关于javascript - 关闭 Firefox 的平滑滚动功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10996067/