Skip to content

Latest commit

 

History

History
35 lines (22 loc) · 760 Bytes

README.md

File metadata and controls

35 lines (22 loc) · 760 Bytes

element-resize-event

Library to make it easy to listen for element resize events

Code borrowed from a blog post by backalleycoder.com.

Install

npm install element-resize-event

Dependencies

This library depends on the availability of requestAnimationFrame and cancelAnimationFrame

Usage

var elementResizeEvent = require("element-resize-event")

var element = document.getElementById("resize")

elementResizeEvent(element, function () {
  console.log("resized!")
  console.log(element.offsetWidth)
})

Unbinding The Event Listener

var unbind = require("element-resize-event").unbind

unbind(element)