# dom-mousemove-dispatcher

> Fire a mousemove on the DOM

Latest version **1.0.1** (published 2016-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install dom-mousemove-dispatcher
pnpm add dom-mousemove-dispatcher
yarn add dom-mousemove-dispatcher
bun add dom-mousemove-dispatcher
```

## 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.0.1 |
| Published | 2016-11-10 |
| First published | 2016-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Quentin Engles |
| Maintainers | hollowdoor |
| Keywords | DOM, event, mouse |

## Links

- npm: https://www.npmjs.com/package/dom-mousemove-dispatcher
- Repository: https://github.com/hollowdoor/dom_mousemove_dispatcher
- Homepage: https://github.com/hollowdoor/dom_mousemove_dispatcher#readme
- Issues: https://github.com/hollowdoor/dom_mousemove_dispatcher/issues
- npm.io page: https://npm.io/package/dom-mousemove-dispatcher

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-11-10
- 1.0.0 — 2016-11-10

## README

Install
-------

`npm install --save dom-mousemove-dispatcher`

Use rollup, browserify, or some other compiler to use this library.

Example
-------

```javascript
import mouseMoveDispatcher from 'dom-mousemove-dispatcher';

const dispatcher = mouseMoveDispatcher(window);

let div = document.querySelector('div')

div.addEventListener('mousemove', (e)=>{
    //This event might have been dispatched by the dispatcher.
    console.log(
        'mouse moving dispatched = ',e.dispatched,
        ' event =', e,
        ' data =', e.data
    );
});

div.addEventListener('mousemove', (e)=>{
    if(e.data === 'myEvent'){
        //The event was dispatched from this listener.
        //To prevent infinite recursion don't refire until the next turn in the event loop.
        e.stopPropagation();
        return;
    }
    //Re-dispatch this event.
    dispatcher.dispatch(div, e, 'myEvent');
});

//Dispatch an event with a clientX property.
setTimeout(()=>dispatcher.dispatch(div, {clientX: 500}), 1000);

```

The Event Object
----------------

The event object you get from firing a mousemove with `dom-mousemove-dispatcher` has additional properties set on it. These are:

-	event.dispatched = "mousemove"
-	event.data = Your data

### mouseMoveDispatcher(object) -> dispatcher

Create a `mousemove` dispatcher that uses `object` to set the default properties on move.

`object` can be anything that can have `mousemove` set through it's `addEventListener` method (window, body, p, div, ...).

### dispatcher.dispatch(element, eventProps, data|undefined) -> cancelled

Dispatch a `mousemove` event.

`element` is the DOM element you wish to fire the mousemove on.

`eventProps` are the properties you want to add to the event.

The optional `data` parameter is an arbitrary javascript value that will be set on a data property on the `mousemove` event object.

### dispatcher.destroy() -> undefined

Cleanup the dispatcher object events, and properties.

About
-----

`dom-mousemove-dispatcher` is a [ponyfill](https://ponyfoo.com/articles/polyfills-or-ponyfills) for `mousemove` event dispatch that is optimized for quick firing of `mousemove`.

Please report any bugs you find.

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