resize-start-stop-events
v1.0.2
Published
Apply `resizestart` and `resizestop` events
Downloads
4
Maintainers
Readme
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-events
or
yarn add resize-start-stop-events
Usage
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 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