这不是我的解决方案,但我认为这是件漂亮整洁的,所以我将只是复制粘贴:
jQuery.extend(jQuery.easing, {
easeOutQuint: function(x, t, b, c, d) {
return c * ((t = t/d - 1) * t * t * t * t + 1) + b;
}
});
var wheel = false,
$docH = $(document).height() - $(window).height(),
$scrollTop = $(window).scrollTop();
$(window).bind('scroll', function() {
if (wheel === false) {
$scrollTop = $(this).scrollTop();
}
});
$(document).bind('DOMMouseScroll mousewheel', function(e, delta) {
delta = delta || -e.originalEvent.detail/3 ||
e.originalEvent.wheelDelta/5; //edit this to your needs - the higher the slower
wheel = true;
$scrollTop = Math.min($docH, Math.max(0, parseInt($scrollTop - delta * 30)));
$($.browser.webkit ? 'body' : 'html').stop().animate({
scrollTop: $scrollTop + 'px'
}, 2000, 'easeOutQuint', function() {
wheel = false;
});
return false;
});
这将覆盖滚动事件的默认行为。
来源和完整学分小提琴用户Szar - 小提琴:https://jsfiddle.net/Szar/xmkwa8ft/
P.S.这发现在1分钟的谷歌搜索使用术语“平滑鼠标滚动CSS”