1. crossvent
Cross-platform browser event handling
crossvent
Package: crossvent
Created by: bevacqua
Last modified: Tue, 14 Jun 2022 03:45:24 GMT
Version: 1.5.5
License: MIT
Downloads: 905,902
Repository: https://github.com/bevacqua/crossvent

Install

npm install crossvent
yarn add crossvent

crossvent

Cross-platform browser event handling

The event handler API used by dominus.

Install

Using Bower

 bower install -S crossvent

Using npm

 npm install -S crossvent

API

The API exposes a few methods that let you deal with event handling in a consistent manner across browsers.

crossvent.add(el, type, fn, capturing?)

Adds an event listener fn of type type to DOM element el.

 crossvent.add(document.body, 'click', function (e) {
  console.log('clicked document body');
});

crossvent.remove(el, type, fn, capturing?)

Removes an event listener fn of type type from DOM element el.

 crossvent.add(document.body, 'click', clicked);
crossvent.remove(document.body, 'click', clicked);

function clicked (e) {
  console.log('clicked document body');
}

crossvent.fabricate(el, type, model?)

Creates a synthetic custom event of type type and dispatches it on el. You can provide a custom model which will be accessible as e.detail.

 crossvent.add(document.body, 'sugar', sugary);
crossvent.fabricate(document.body, 'sugar', { onTop: true });

function sugary (e) {
  console.log('synthetic sugar' + e.detail.onTop ? ' on top' : '');
}

License

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code