在鼠标滚轮上平滑滚动?

Pau*_*Pau 2 javascript jquery plugins

而不是正常的鼠标滚动速度,我想使它更慢,更平滑,并在现代浏览器中尽可能一致.

我已经尝试使用一些插件,如NiceScroll(https://nicescroll.areaaperta.com/).

但是在安装之后,出于某种原因它会出现溢出:隐藏; 在我的内容上,之后无法滚动.我不需要任何自定义设计的滚动条.我只需要在使用鼠标滚动或垂直滚动​​条时滚动更平滑:

http://pervolo.com/

有人可以请教我这个吗?我计划使用skrollr插件(https://github.com/Prinzhorn/skrollr)以及平滑滚动.

Ric*_*ock 5

这可能会让你前进:

$(window).on('mousewheel DOMMouseScroll', function(e) {
  var dir,
      amt = 100;

  e.preventDefault();
  if(e.type === 'mousewheel') {
    dir = e.originalEvent.wheelDelta > 0 ? '-=' : '+=';
  }
  else {
    dir = e.originalEvent.detail < 0 ? '-=' : '+=';
  }      

  $('html, body').stop().animate({
    scrollTop: dir + amt
  },500, 'linear');
})
Run Code Online (Sandbox Code Playgroud)

DOMMouseScroll并且e.originalEvent.detail是Firefox所必需的.更改amt为您想要的滚动距离,并更改500为您想要的滚动速度.

小提琴:http: //jsfiddle.net/utcsdyp1/1