Mousewheel event detection not currently working in Firefox
javascript, jquery, mousewheel
Solution
Your code generates an error in the console. The line:
var evt = event || e || window.event;
is incorrect; there's no "event" variable in scope. You can just use "e" directly. The jQuery code will make sure your handler gets the event parameter as a parameter. Or:
$(document).unbind('mousewheel DOMMouseScroll').on('mousewheel DOMMouseScroll', function(evt) {
var delta = evt.detail < 0 || evt.wheelDelta > 0 ? 1 : -1;
if (delta < 0) {
// scroll down
} else {
// scroll up
}
});
Problem
For some reason I'm having trouble trying to recognize the mousewheel event in Firefox. This is working in IE, Chrome, Safari, Opera but not FF. I am attaching an event listener on DOMMouseScroll, which should be recognized in FF. Fiddle demo ``` $(document).unbind('mousewheel DOMMouseScroll').on('mousewheel DOMMouseScroll', function(e) { var evt = event || e || window.event; var delta = evt.detail < 0 || evt.wheelDelta > 0 ? 1 : -1; if (delta < 0) { // scroll down } else { // scroll up } }); ```