This package has been deprecated

Author message:

remove

resize-xy

1.3.1 • Public • Published

resize-xy

Custom event for detect individually resizes on horizontal(x) or vertical (y). Useful f

Motivation

The default resize event triggers whenever an horizontal or vertical changes occurs. Many mobile devices like Android and iOS triggers vertical resize events while the user scrolls, so if you need watch horizontal change, its necessary manually check if the window size has really changed.

Browser support

Make sure you are using:

Simple use case

// Simple case
import resizeXY from 'resize-xy';

// Attach the plugin on `window`:
window.addEventListener('resize', resizeXY());

// Attach your events to `window`
window.addEventListener('resize-x', (event) => {
  console.log(`Changed X from ${event.detail.oldValue} to ${event.detail.newValue}`)
});

window.addEventListener('resize-y', (event) => {
  console.log(`Changed Y from ${event.detail.oldValue} to ${event.detail.newValue}`)
});

Options

const options = {
  namespace: '',
  interval: 500
};

window.addEventListener('resize', resizeXY(options));

options.namespace

Allow define custom namespace for the event, if value is 'myCustomNamespace-', then, you should listen for myCustomNamespace-resize-x and myCustomNamespace-resize-y

options.interval

Interval between multiple resize events.

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i resize-xy

    Weekly Downloads

    1

    Version

    1.3.1

    License

    MIT

    Last publish

    Collaborators

    • mateuspv