is-support-passive-events

1.1.0 • Public • Published

is-support-passive-events

Determine if the current client support passive events.

New in v1.1.0 : add eventOptions() to automatically fallback to basic options if passive events are not supported.

Installation

npm install is-support-passive-events

Usage example

import isSupportPassiveEvents from 'is-support-passive-events';
// When you're declaring your event, check if passive events are supported
const options = isSupportPassiveEvents
  ? { passive: true, capture: false }
  : false;
  
document.addEventListener('scroll', handler, options);

eventOptions(options [,fallback]) (function)

Automatically use a fallback if passive events are not supported.

Receives the following parameters :

  • options (object)
  • fallback (boolean) => Default value: false
import { eventOptions } from 'is-support-passive-events';
document.addEventListener('scroll', handler, eventOptions({
  passive: true, capture: false
}));

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.0
    22
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.0
    22
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i is-support-passive-events

Weekly Downloads

22

Version

1.1.0

License

MIT

Unpacked Size

3.49 kB

Total Files

4

Last publish

Collaborators

  • antoinedemailly