1.0.0 • Published 3 years ago
scroll-start-stop-events v1.0.0
Events for scrollstart & scrollstop
Simple and lightweight package to apply scrollstart and scrollstop events, which are triggered at the beginning and the end of a scroll event.
Installation
npm i scroll-start-stop-eventsor
yarn add scroll-start-stop-eventsUsage
Import scroll-start-stop-events to apply scrollstart and scrollstop events to the window object.
import 'scroll-start-stop-events'Add event listeners:
window.addEventListener('scrollstart', scrollstartHandler);
window.addEventListener('scrollstop', scrollstopHandler);Remove event listeners:
window.removeEventListener('scrollstart', scrollstartHandler);
window.removeEventListener('scrollstop', scrollstopHandler);API
For more control import the default function from scroll-start-stop-events/api.
import applyScrollStartStopEvents from 'scroll-start-stop-events/api'
applyScrollStartStopEvents(window, 200, 'isScrolling')Parameters:
element… the element to apply the scroll events to (default:window)stopDelay… the delay inmsafter thescrollstopevent should fire, when scrolling stops (default:200)isScrolling… the name of the property that is attached to theelement– will betruewhile scrolling (default:'isScrolling')
To check if the element is currently scrolling, simply use its property element.isScrolling
1.0.0
3 years ago