這不是我的解決方案,但我認爲這是件漂亮整潔的,所以我將只是複製粘貼:
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」