'Ghost onwheel event Javascript with Magic Mouse Apple

I make a function to handle wheel event on my program.

document.onwheel = function(event){
console.log(event);
}

I have tested the method on several controllers and browser.

I have a specific problem with the Magic Mouse controller of Apple on Safari and Chrome browser.

When I move mouse with left click pressed (drag and drop with left click button method) and then I remove left click I receive several wheel event with "wheelDeltaX" or "deltaX" values.



Solution 1:[1]

Tested on a classic mouse with windows/chrome browser. Problem do not appears.

Solution 2:[2]

It is because the mouse inertia.

You can disable it in System Preferences > Accessibility > Mouse Options > Scrolling.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cconigli
Solution 2 Arian Fornaris