Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elo7/events-amd
Event.js is a tiny library to add and remove events in any browser.
https://github.com/elo7/events-amd
amd events front-end javascript lib martell nymeros
Last synced: about 2 months ago
JSON representation
Event.js is a tiny library to add and remove events in any browser.
- Host: GitHub
- URL: https://github.com/elo7/events-amd
- Owner: elo7
- License: bsd-3-clause
- Created: 2015-04-06T17:43:03.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-04-28T22:19:34.000Z (over 3 years ago)
- Last Synced: 2024-11-08T15:00:54.502Z (about 2 months ago)
- Topics: amd, events, front-end, javascript, lib, martell, nymeros
- Language: JavaScript
- Homepage:
- Size: 24.4 KB
- Stars: 1
- Watchers: 101
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Event-amd
_Event-amd add/remove event library_
Event.js is a tiny library to add and remove events in any browser. This library uses [amd](http://en.wikipedia.org/wiki/Asynchronous_module_definition) structure.
## Install
Install : `npm install elo7-events-amd`
## Dependency
Event-amd depends on an [amd](http://en.wikipedia.org/wiki/Asynchronous_module_definition) implementation. We suggest [define-async](https://www.npmjs.com/package/define-async) implementation for dependency lookup.
## Parameters
#### element: DocumentElement
Ex.: document.querySelector('#link')#### event: String
Event that will be added or removed from the _element_Ex.: 'click'
#### callback: Function
Function that will be called when the _event_ is triggered, only for _addEvent_Ex.: function(){ ... }
#### configs: Object (optional) or String (optional)
You can pass a config with the following parameters:- named: like eventCategory
You can add multiple '_events_' of the same type (e.g: _click_) and use the _eventCategory_ parameter to remove certain events when needed.Ex.:
event.addEvent(element, 'click', callback, { named: 'tracking' });- passive: Boolean (optional)
If _true_, indicates that the function specified by listener will never call preventDefault().
Only works on `addEvent`Ex.:
event.addEvent(element, 'click', callback, { passive: true });Ex.:
event.addEvent(element, 'click', callback, { named: 'tracking', passive: true });Or you can use the shorthand and only pass the eventCategory as parameter.
Ex.:
event.addEvent(element, 'click', callback, 'tracking');
event.addEvent(element, 'click', callback, 'action');
event.removeEvent(element, 'click', 'action');* `removeEvent` only supports Strings as last parameter
## Example
``` js
define(['event'], function(event) {
event.addEvent(element, event, callback, eventCategory);
event.removeEvent(element, event, eventCategory);
});
```## License
Event-amd is released under the [BSD](https://github.com/elo7/event-amd/blob/master/LICENSE). Have at it.
* * *
Copyright :copyright: 2019 Elo7# event-amd