javascript - mousewheel.scroll 在 Firefox 中不工作

标签 javascript jquery html css fullpage.js

我正在使用 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)

Original source

关于javascript - mousewheel.scroll 在 Firefox 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41326568/

相关文章:

javascript - React ES6 SystemJS - 未捕获( promise )错误 : Unexpected token <(…)

JavaScript 对象和类

javascript - 用JS创建带有onMouseOver效果的DIV

javascript - 使用 pureJS 拖放,无后端

带有数组索引的 PHP 发布表单

javascript - ASP :Checkbox Autopostback after change when the value has already been changed via Javascript

javascript - 如何将链接添加到 "Title"或 "image"

Javascript regExp 输入验证

Jquery选择器: Count element with attribute on the second tr

css - 透明的 div 背景,带有淡淡的颜色?