event.preventDefault(); not stopping mousewheel in Firefox
This is still one of the top posts when I search for the issue of Firefox scrolling despite preventing the scroll event.
Firefox triggers two events on mouse scroll: DOMMouseScroll
and MozMousePixelScroll
. See https://github.com/jquery/jquery-mousewheel/issues/45#issuecomment-11749359 It is necessary to prevent the MozMousePixelScroll
event.
According to https://developer.mozilla.org/en-US/docs/Web/Events/MozMousePixelScroll the most modern event name is wheel
, which appears to work with my version of Firefox (55) and Chrome (61). Probably this is what you should be using. See https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/WheelEvent
Here's a JSFiddle:
https://jsfiddle.net/ahpy9f66/