Skip to content

lucasvallenet/js-custom-events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

@lucasvallenet/js-custom-events

npm

Add custom events to window or DOM element

Installation

yarn add @lucasvallenet/js-custom-events

npm i @lucasvallenet/js-custom-events

Usage

Add an event to window
// Import event
import { scrollstart } from '@lucasvallenet/js-custom-events'

// Execute function
scrollstart()

// Add callback (window by default)
window.addEventListener('scrollstart', () => console.log('scrollstart'))
Add an event to a DOM element
// Import event
import { movestart } from '@lucasvallenet/js-custom-events'

// Get DOM element
const myDiv = document.getElementById('my-div')

// Execute function with the DOM element as parameter
movestart(myDiv)

// Add callback 
myDiv.addEventListener('movestart', () => console.log('movestart'))

Available events

Scroll triggers

scrollstart | scrollend

Scroll directions Y

scrollup | scrolldown

Mouse move

movestart | moveend

About

Add custom events to window

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published