Simple and lightweight package to apply resizestart
and resizestop
events, which are triggered at the beginning and the end of a resize
event.
npm i resize-start-stop-events
or
yarn add resize-start-stop-events
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);
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 inms
after theresizestop
event should fire, when resizing stops (default:200
) -
isResizing
… the name of the property that is attached to theelement
– will betrue
while resizing (default:'isResizing'
)
To check if the element
is currently resizing, simply use its property element.isResizing