resize-start-stop-events

1.0.2 • Public • Published

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

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i resize-start-stop-events

      Weekly Downloads

      2

      Version

      1.0.2

      License

      MIT

      Unpacked Size

      4.3 kB

      Total Files

      5

      Last publish

      Collaborators

      • formfcw