jQuery 自定义滚动条 - 鼠标滚轮太慢
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15546217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Custom scrollbar - mouse wheel too slow
提问by Husamuddin
I'm working on a site which contains a div with a custom scroll bar. My problem is that the mouse wheel doesn't work properly, it's too slow.
我正在处理一个包含带有自定义滚动条的 div 的站点。我的问题是鼠标滚轮不能正常工作,太慢了。
The site is http://alaaelseifi.net/and the custom scroll library is from http://manos.malihu.gr/
该站点是http://alaaelseifi.net/,自定义滚动库来自http://manos.malihu.gr/
The script issupposed to be like this:
脚本应该是这样的:
$(window).load(function() {
$(".scroll-pane").mCustomScrollbar();
//code that make scrolling with mouse faster
});
回答by obivandamme
You can set the speed of scrolling in the options as described in the scoll libraries documentation here: http://manos.malihu.gr/jquery-custom-content-scroller/
您可以在此处的 scoll 库文档中描述的选项中设置滚动速度:http: //manos.malihu.gr/jquery-custom-content-scroller/
I think what you are looking for is something like this:
我认为你正在寻找的是这样的:
$(".scroll-pane").mCustomScrollbar({
mouseWheelPixels: 50 //change this to a value, that fits your needs
})
Just play around with the value until scolling is as fast as you need it.
只需调整该值,直到滚动速度达到您需要的速度。
回答by Melinda Rabenstein
I also noticed that the "slow" feeling on my site was due to the fact that scroll inertia is turned on by default if you use the following it will turn that off and cause the bar to not lag trying :
我还注意到,我网站上的“缓慢”感觉是由于默认情况下启用了滚动惯性,如果您使用以下内容,它将关闭它并导致栏不滞后尝试:
$(".scroll-pane").mCustomScrollbar({
scrollInertia: 0
});
回答by Nathan Webb
As Melinda mentioned, scrollInertia does the trick, but rather than turning if off completely, you can adjust it to make it faster, but still smooth. Turning it off completely made the scrolling too jumpy for my liking, and made it jump over many options. That made it impossible to get to some options.
正如梅琳达所提到的,scrollInertia 可以解决问题,但是如果完全关闭,您可以调整它以使其更快,但仍然平滑,而不是完全关闭。完全关闭它会使滚动过于跳跃,我不喜欢它,并使其跳过许多选项。这使得无法获得某些选项。
I found that 60ms was an ideal setting:
我发现 60ms 是一个理想的设置:
$(".mCustomScrollbar").mCustomScrollbar({
scrollInertia: 60,
});
As the docs say:
正如文档所说:
Set the amount of scrolling momentum as animation duration in milliseconds. Higher value equals greater scrolling momentum which translates to smoother/more progressive animation. Set to 0 to disable.
将滚动动量设置为动画持续时间(以毫秒为单位)。更高的值等于更大的滚动动量,这意味着更平滑/更渐进的动画。设置为 0 以禁用。
回答by Junaid
this worked for me though, I had to combine two of the answers here,
不过这对我有用,我必须在这里结合两个答案,
scrollInertia: 0
mouseWheelPixels: 170,
autoDraggerLength:false,
回答by Dishan TD
This works for me.
这对我有用。
$("#scroll").mCustomScrollbar({
mouseWheelPixels: 170,
autoDraggerLength:false
});