Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/susisu/ev
A simple DOM-like event system
https://github.com/susisu/ev
Last synced: 3 months ago
JSON representation
A simple DOM-like event system
- Host: GitHub
- URL: https://github.com/susisu/ev
- Owner: susisu
- License: mit
- Created: 2014-12-20T07:11:34.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-31T06:32:35.000Z (over 9 years ago)
- Last Synced: 2024-01-04T18:03:12.823Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 176 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eV
The eV (electronvolt) provides a simple DOM-like event system.## Installation
``` shell
$ npm install electronvolt
```## Example
``` javascript
var ev = require("electronvolt");// create event nodes
var node = new ev.EventNode();
var parent = new ev.EventNode();// compose event flow
node.parentNode = parent;var listener = function (event) {
switch (event.eventPhase) {
case ev.EventPhase.AT_TARGET:
console.log("at target");
break;
case ev.EventPhase.BUBBLING_PHASE:
console.log("bubbling phase");
break;
case ev.EventPhase.CAPTURING_PHASE:
console.log("capturing phase");
break;
}
};// add event listeners
node.addEventListener("example", listener);
parent.addEventListener("example", listener);
parent.addEventListener("example", listener, true);// dispatch event into the event flow
node.dispatchEvent(new ev.Event("example", true));
// -> capturing phase
// -> at target
// -> bubbling phase
```## License
[MIT License](http://opensource.org/licenses/mit-license.php)## Author
Susisu ([GitHub](https://github.com/susisu), [Twitter](https://twitter.com/susisu2413))