我正在使用 fullPage.js 处理单页幻灯片。
这是我的演示:
http://codepen.io/r0ysy0301/pen/rWKxQB
我在向上或向下滚动时创建了一个事件;按钮 next
将改变位置。
接下来,我继续创建一个变量并为 active
类分配一个标志来检查。如果该 active
,请更改 next
按钮的 CSS 位置。
但似乎它只适用于 Chrome,我在 Firefox 上测试并没有发生任何事情。
我认为 mousewheel
事件有问题,因为我还测试了 keyup
事件,但它运行良好。
最佳答案
Firefox 无法识别 "mousewheel"
。以下是锻炼。
在监听器中使用这两个事件
$(window).on("mousewheel DOMMouseScroll", function(e){
e.preventDefault();
});
或单独处理 firefox。
var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel" //FF doesn't recognize mousewheel as of FF3.x
if (document.attachEvent) //if IE (and Opera depending on user setting)
document.attachEvent("on"+mousewheelevt, function(e){alert('Mouse wheel movement detected!')})
else if (document.addEventListener) //WC3 browsers
document.addEventListener(mousewheelevt, function(e){alert('Mouse wheel movement detected!')}, false)
关于javascript - mousewheel.scroll 在 Firefox 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41326568/