2.0.0 • Published 6 years ago

@spon/domevents v2.0.0

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

Install

yarn add @spon/domevents

or

npm install @spon/domevents --save

import domEvents from '@spon/domevents'

const { addEvents, removeEvents } = domEvents(document.body)

addEvents({
	'click [data-toggle-button]': (e, elm) => {
		e.preventDefault()
		elm.classList.toggle('is-active')
	}
})

All events, by default are delegated to the node given to the initial setup. If you want to delegate to a different element, you can pass in a Dom node as the first argument , eg

addEvents(document.querySelector('.my-node'), {
	'click [data-toggle-button]': (e, elm) => {
		e.preventDefault()
		elm.classList.toggle('is-active')
	}
})
2.0.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago