# crossvent

> Cross-platform browser event handling

Latest version **1.5.5** (published 2016-10-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install crossvent
pnpm add crossvent
yarn add crossvent
bun add crossvent
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.5 |
| Published | 2016-10-18 |
| First published | 2015-03-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Nicolas Bevacqua |
| Maintainers | bevacqua |

## Links

- npm: https://www.npmjs.com/package/crossvent
- Repository: https://github.com/bevacqua/crossvent
- Issues: https://github.com/bevacqua/crossvent/issues
- npm.io page: https://npm.io/package/crossvent

## Dependencies (1)

- [custom-event](https://npm.io/package/custom-event.md) ^1.0.0

## Recent versions

- 1.5.5 (latest) — 2016-10-18
- 1.5.4 — 2015-08-25
- 1.5.3 — 2015-08-25
- 1.5.2 — 2015-08-24
- 1.5.1 — 2015-08-22
- 1.5.0 — 2015-07-08
- 1.4.0 — 2015-07-03
- 1.3.2 — 2015-06-30
- 1.3.1 — 2015-03-17
- 1.3.0 — 2015-03-17
- 1.2.0 — 2015-03-10
- 1.1.0 — 2015-03-03
- 1.0.0 — 2015-03-02
- 0.0.1 — 2015-03-02

## README

# crossvent

> Cross-platform browser event handling

The event handler API used by [dominus][1].

# Install

Using Bower

```shell
bower install -S crossvent
```

Using `npm`

```shell
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`.

```js
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`.

```js
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`.

```js
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

[1]: https://github.com/bevacqua/dominus

---
_Source: https://npm.io/package/crossvent · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
