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