Skip to content

t4chibana/event-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Event switch

easily manage javascript event handling

About

Easily manipulate event registration and deletion. It also supports events registered with anonymous functions.

Usage

Installing

<script src="/path/to/plugin/eventSwitch.min.js">

Regist event

var clickEvent = esw('.trigger','click',function(e){ console.log(e) });

Option

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])

API

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

License

MIT

Releases

No releases published

Packages

No packages published