What is normalize-wheel-es?
The normalize-wheel-es package is a utility for normalizing the wheel delta across different browsers. It helps in handling the inconsistencies in the way different browsers report the wheel events, providing a consistent and reliable way to handle mouse wheel interactions.
What are normalize-wheel-es's main functionalities?
Normalize Wheel Event
This feature normalizes the wheel event across different browsers. The code sample demonstrates how to import the normalizeWheel function and use it to handle the wheel event, logging the normalized pixel values for the X and Y axes.
import normalizeWheel from 'normalize-wheel-es';
const handleWheel = (event) => {
const normalized = normalizeWheel(event);
console.log(normalized.pixelX, normalized.pixelY);
};
document.addEventListener('wheel', handleWheel);
Other packages similar to normalize-wheel-es
normalize-wheel
The normalize-wheel package provides similar functionality to normalize-wheel-es by normalizing the wheel delta across different browsers. It is a widely used package and offers a similar API for handling wheel events.
wheel
The wheel package is another alternative that provides utilities for handling mouse wheel events. It offers additional features such as handling touchpad gestures and providing more detailed information about the wheel event.
Normalize Wheel
Mouse wheel normalization across multiple multiple browsers.
Original source
This code is extracted and from Facebook's Fixed Data Table. Apart from import fixes, the code is unmodified.
Usage
Just add it as an dependency in npm.
You can use it as follows:
import normalizeWheel from 'normalize-wheel-es';
document.addEventListener('mousewheel', function (event) {
const normalized = normalizeWheel(event);
console.log(normalized.pixelX, normalized.pixelY);
});
License
See the LICENSE
file.