1.0.2 • Published 2 years ago

resize-start-stop-events v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Events for resizestart & resizestop

NPM version Bundle size GitHub license

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 in ms after the resizestop event should fire, when resizing stops (default: 200)
  • isResizing … the name of the property that is attached to the element – will be true while resizing (default: 'isResizing')

To check if the element is currently resizing, simply use its property element.isResizing