The mouse wheel’s scrolling speed varies with the choice of the web browser, even the DOM events and methods to change the scrolling speed are not the same. To provide zoom and animation on a web page, it is generally required to configure mouse speed. The speed of the wheel can be controlled by normalizing the distance of the wheel has traveled. There are various techniques to change the speed of the mouse wheel in different web browsers.
For IE, Safari, Chrome: The mousewheel event is fired when a mouse wheel or similar device is operated. The below function can be used to control the speed of the mouse wheel. The normalized distance can be used in functions like animate, translate of the Web API to provide different transformations and animations.
Firefox: In Firefox, the DOMMouseScroll event is fired when mousewheel is operated. As in above case, normalized distance returned by the below function can be used in animate function to provide different transformations.
- Program: We can also make a function that can normalize the scrolling speed of mousewheel/trackpad for various web browsers, and one function will serve the purpose for various browsers.