Nurturing Palpable Magnificence
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

resize-event

1.2.1 • Public • Published

resize-event

Detect resize on an element without polling or iframes

build status NPM version

This uses a MutationObserver to detect changes to the style attribute of an element and then compares the width/height to check if it has changed.

A polyfill is provided which will use polling on older browsers.

usage

var onResize = require("resize-event");
 
// Create or select an element, must be in the DOM
var element = document.createElement("div");
document.body.appendChild(element);
 
// Bind the event
onResize(element, function() {
  console.log("element was resized");
});
 
// Trigger the event
element.style.width = "500px";

install

npm install resize-event --save

Then use a CommonJS compatible module bundler to require('resize-event').

license

(c) 2018 Kyle Robinson Young. MIT License

install

npm i resize-event

Downloadsweekly downloads

28

version

1.2.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability