Javascript 如何仅在 fullpage.js 中禁用鼠标滚动触发器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27245933/
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
How to disable mouse scroll trigger in fullpage.js only
提问by infiniteloop
In fullpage.js core functions
在 fullpage.js 核心功能中
How to customize such that when set option autoScrolling: true.
如何自定义,以便在设置选项 autoScrolling: true 时。
1.only disable mouse scroll behavior trigger in section scrolling control.
1.仅在部分滚动控件中禁用鼠标滚动行为触发器。
2.other keyboard scroll triggers still working. (such as keyup keydown end home etc)
2.其他键盘滚动触发器仍然有效。(例如keyup keydown end home等)
here is the fullpage.js code from git: https://github.com/ajgagnon/fullPage.js/blob/master/jquery.fullPage.js
这是来自 git 的 fullpage.js 代码:https: //github.com/ajgagnon/fullPage.js/blob/master/jquery.fullPage.js
Explaination: why need to disable mouse scroll sometimes. Because there are scroll sensitivity issues in fullpage.js when "scrollOverflow: true". However, if you totally disabled the "autoScrolling: true" option, by default keyboard trigger still allow to scroll up down left right. ( "keyboardScrolling: true" by default; )
解释:为什么有时需要禁用鼠标滚动。因为 fullpage.js 在 "scrollOverflow: true" 时存在滚动敏感问题。但是,如果您完全禁用“autoScrolling: true”选项,默认情况下键盘触发器仍允许上下左右滚动。(默认为“键盘滚动:true”;)
However,I discovered when "scrollOverflow: false" option together with "keyboardScrolling: true", the content will shake instantly the moment you press down the arrow keys. don't know how to fix, so it's my purpose to keep scrollOverflow:true while disable mouse scroll only. then will be no issue. )
然而,我发现当“scrollOverflow: false”选项与“keyboardScrolling: true”一起使用时,当你按下方向键时,内容会立即抖动。不知道如何解决,所以我的目的是在仅禁用鼠标滚动时保持 scrollOverflow:true 。那么就没有问题了。)
回答by Ferret
How about:
怎么样:
$(function()
{
$('#fullpage').fullpage({
...
});
$.fn.fullpage.setMouseWheelScrolling(false);
$.fn.fullpage.setAllowScrolling(false);
});
回答by Alvaro
However, if you totally disabled the "autoScrolling: true" option, by default keyboard trigger still allow to scroll up down left right. ( "keyboardScrolling: true" by defa
但是,如果您完全禁用“autoScrolling: true”选项,默认情况下键盘触发器仍允许上下左右滚动。( "keyboardScrolling: true" by defa
Not anymore since fullPage.js 2.4.9. autoScrolling:falsewill disable the auto scroll with keyboard as well.
从 fullPage.js 2.4.9 开始就没有了。autoScrolling:false也将禁用键盘自动滚动。
回答by Antonio Junior
Alvaro, to disable keyboard you should use: keyboardScrolling: false
Alvaro,要禁用键盘,您应该使用: keyboardScrolling: false

