easily manage javascript event handling
Easily manipulate event registration and deletion. It also supports events registered with anonymous functions.
Installing
<script src="/path/to/plugin/eventSwitch.min.js">
Regist event
var clickEvent = esw('.trigger','click',function(e){ console.log(e) });
var clickEvent = esw(trigger,event,listener,option);
Option | Type | Description |
---|---|---|
trigger | string / object | css selector or DOM object(document, window...etc) |
event | string | event name |
listener | function(event) | function. can use anonymous function |
option | anything | eventlistner standard setting(option or useCapture) If you want to make different settings for addEventlistener and removeEventlistener. It's possible by using arrays.(ex. [addEventlistener_option, removeEventlistener_option]) |
var clickEvent = esw(trigger,event,listener,option);
//remove event
clickEvent.switch('off')
//restore event & event attach
clickEvent.switch('on')
//check event state(boolean)
clickEvent.isActive
MIT