Jem Jem - 9 months ago 28
Javascript Question

Javascript: Capture mouse wheel event and do not scroll the page?

I'm trying to prevent a mousewheel event captured by an element of the page to cause scrolling.

I expected 'false' as last parameter to have the expected result, but using the mouse wheel over this "canvas" element still causes scrolling:

this.canvas.addEventListener('mousewheel',function(event){mouseController.wheel(event)}, false);

Outside of this "canvas" element, the scroll needs to happen. Inside, it must only trigger the .wheel() method.
What am I doing wrong?



You can do so by returning false at the end of your handler.

    return false; 
}, false);