Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

crossvent

bevacqua916.8kMIT1.5.5

Cross-platform browser event handling

readme

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

changelog

1.5.4 Mortal Kombat 3

  • Crossvent now ignores API limitations on the server-side, instead of throwing

v1.5.2 Fix Up

  • Fixed a bug in IE8 where attempting to remove an undefined event listener would throw

v1.5.1 Power Up

  • Crossvent now exports an empty API on the server-side, instead of throwing

v1.5.0 Classic Poets

  • Fall back to classic events for non-made-up event types

v1.4.0 Fabricator

  • Added optional custom event model for .fabricate

v1.3.2 Ice Bug

  • e.which gets normalized across browsers, e.keyCode is used if not present

v1.3.1 Fire Bug

  • Use fireEvent and createEventObject when their modern counterparts are missing

v1.2.0 Flag The Bug

  • Added ability to use a capture parameter in event removal as well

v1.1.0 Capture The Flag

  • Added ability to use a capture parameter

v1.0.0 IPO

  • Initial Public Release