New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

event-map

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-map

quickly add a list of event listeners to a view, inspired by Backbone.View event delegation

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

event-map

A module to ease the addition and removal of a mapping of delegated listeners to a view. Inspired by Backbone.View's delegateEvents. A mapping consists of an object where the key is an event and optionally a selector as well and the value is a listener function.

NPM

Install

npm install event-map --save

Usage

eventMap([domElement,] map [, useCapture])

On a domElement, append these listeners delegated to the provided selectors:

var removeListeners = eventMap(domElement, {
    'click .btn': function(event){ console.log(event.target + 'clicked'); },
    'mouseover h1, h2, a': onRollover,
    'touchstart': onTouchStart
});


//at a later timer, clean up:
removeListeners();

If no domElement is provided, all events are placed on document:


var removeListeners = eventMap({
    'touchstart': onTouchStart,
    'touchmove': onTouchMove,
    'touchend': onTouchEnd
}, true);

License

MIT, see LICENSE.md for details.

Keywords

addEventListener

FAQs

Package last updated on 15 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts