What is has-passive-events?
The has-passive-events npm package is a utility that helps you determine if the browser supports passive event listeners. Passive event listeners can improve the performance of scroll events by allowing the browser to perform optimizations.
What are has-passive-events's main functionalities?
Check for passive event listener support
This feature allows you to check if the current browser supports passive event listeners. The code sample demonstrates how to use the package to log whether passive event listeners are supported.
const hasPassiveEvents = require('has-passive-events');
if (hasPassiveEvents) {
console.log('Passive event listeners are supported.');
} else {
console.log('Passive event listeners are not supported.');
}
Other packages similar to has-passive-events
detect-passive-events
The detect-passive-events package provides a similar functionality by detecting support for passive event listeners in the browser. It offers a more detailed API, allowing you to check for support and also providing a way to add event listeners with passive options.
passive-events-support
The passive-events-support package is another alternative that checks for passive event listener support. It is lightweight and straightforward, similar to has-passive-events, but may have different implementation details and performance characteristics.
has-passive-events
Check if event listener options are available on the current device. Try it out.
const hasPassive = require('has-passive-events')
hasPassive ? element.addEventListener('wheel', handler, {passive: true}) : element.addEventListener('wheel', handler)
If you find edge case, please address issues.