admin管理员组文章数量:1302267
Below code is working fine on chrome however it doesn't work on Mozilla for some reason that I am not aware yet. Am i missing something ?
$(window).bind('mousewheel', function(event) {
if (event.originalEvent.wheelDelta >= 0) {
$('#currentMove').html('Movement: Scroll up');
$('#currentMove').css('background','#98FB98');
scrollUp++;
$('#scrollUp').html(scrollUp);
}
else {
$('#currentMove').html('Movement: Scroll down');
$('#currentMove').css('background','#FFB6C1');
scrollDown++;
$('#scrollDown').html(scrollDown);
}
});
Here is my fiddle: / Appreciate your help with this.
Below code is working fine on chrome however it doesn't work on Mozilla for some reason that I am not aware yet. Am i missing something ?
$(window).bind('mousewheel', function(event) {
if (event.originalEvent.wheelDelta >= 0) {
$('#currentMove').html('Movement: Scroll up');
$('#currentMove').css('background','#98FB98');
scrollUp++;
$('#scrollUp').html(scrollUp);
}
else {
$('#currentMove').html('Movement: Scroll down');
$('#currentMove').css('background','#FFB6C1');
scrollDown++;
$('#scrollDown').html(scrollDown);
}
});
Here is my fiddle: https://jsfiddle/w0wffbxc/ Appreciate your help with this.
Share asked Nov 29, 2017 at 9:09 shifushifu 6708 silver badges38 bronze badges 2- Possible duplicate of stackoverflow./questions/16788995/… – moon Commented Nov 29, 2017 at 9:15
- 1 Possible duplicate of mousewheel event is not triggering in firefox browser – moon Commented Nov 29, 2017 at 9:16
2 Answers
Reset to default 7Here's your sqlfiddle fixed.
You should use wheel
as mousewheel
is not recognized by Firefox since version 3. Also with wheel
, you should use event.originalEvent.deltaY
instead.
Use wheel event instead. Its more of a standard now. This page also provides polyfills for old browsers https://developer.mozilla/en-US/docs/Web/Events/wheel
Ex
$(window).on('wheel', function(event){
// deltaY obviously records vertical scroll, deltaX and deltaZ exist too
if(event.originalEvent.deltaY < 0){
// wheeled up
console.log("Works Up");
}
else {
// wheeled down
console.log("Works Down");
}
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
本文标签: javascriptmousewheel event not working on firefoxStack Overflow
版权声明:本文标题:javascript - mousewheel event not working on firefox - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741711536a2393873.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论