Node Promiscuous Modules

    elo7-events-amd

    1.2.1 • Public • Published

    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 structure.

    Install

    Install : npm install elo7-events-amd

    Dependency

    Event-amd depends on an amd implementation. We suggest 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

    define(['event'], function(event) {
        event.addEvent(element, event, callback, eventCategory);
        event.removeEvent(element, event, eventCategory);
    });

    License

    Event-amd is released under the BSD. Have at it.


    Copyright ©️ 2019 Elo7# event-amd

    Install

    npm i elo7-events-amd

    DownloadsWeekly Downloads

    38

    Version

    1.2.1

    License

    BSD-3-Clause

    Unpacked Size

    8.65 kB

    Total Files

    7

    Last publish

    Collaborators

    • elo7tech