mousewheel.scroll not working in Firefox

739 Views Asked by At

I am working with one-page slide using fullPage.js.

Here is my demo:

http://codepen.io/r0ysy0301/pen/rWKxQB

I create an event when using scroll up or down; button next will change position.

Next, I continue created a variable and assign active class is a flag to check. If that active, change CSS position of button next.

But seem it only working with Chrome, I tested on Firefox and not happen anything.

I think problem at event mousewheel because I also tested with event keyup but it working perfectly.

1

There are 1 best solutions below

1
On BEST ANSWER

Firefox doesn't recognize "mousewheel". Followings are workouts.

Use both events in listener

$(window).on("mousewheel DOMMouseScroll", function(e){
    e.preventDefault();
});

OR address firefox separately.

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