Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/07akioni/evtd
Event delegation with native events and extended events.
https://github.com/07akioni/evtd
Last synced: about 2 months ago
JSON representation
Event delegation with native events and extended events.
- Host: GitHub
- URL: https://github.com/07akioni/evtd
- Owner: 07akioni
- License: mit
- Created: 2020-11-04T05:57:03.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-07T03:58:28.000Z (almost 2 years ago)
- Last Synced: 2024-10-23T20:07:15.933Z (2 months ago)
- Language: TypeScript
- Homepage: https://evtd.vercel.app
- Size: 61.5 KB
- Stars: 23
- Watchers: 3
- Forks: 5
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-naive - evtd - Event delegation with native events and extended events in a small library. (List / Related To NaiveUI)
README
# evtd
Event delegation with native events and extended events in a small library.(Only 300 lines of codes)
## Docs
[evtd](https://evtd.vercel.app/)## Basic Usage
```ts
import { on, off } from 'evtd'function handleClick () {
console.log('click')
}// register event
on(window, 'click', handleClick)
on(document, 'click', handleClick)
on(eventTarget, 'click', handleClick)// evtd has 2 extended events
on(eventTarget, 'clickoutside', handleClick)
on(eventTarget, 'mousemoveoutside', handleClick)// unregister
const handleClick2 = () => console.log('click2')
on(eventTarget, 'click', handleClick2)
off(eventTarget, 'click', handleClick2)// capture
on(eventTarget, 'click', handleClick2, true)
off(eventTarget, 'click', handleClick2, true)
```## License
MITInspired by [delegated-events](https://github.com/dgraham/delegated-events)