dom-resize
Version:
Polyfill to make it easy to listen for element resize events
26 lines (18 loc) • 582 B
Markdown
Library to make it easy to listen for element resize events
Forked from: https://github.com/KyleAMathews/element-resize-event
`npm install dom-resize`
This library depends on the availability of `requestAnimationFrame` and `cancelAnimationFrame`
```javascript
import { resizeListen, resizeUnlisten } from 'dom-resize'
const target = document.getElementById("target")
// Subscribe to resize event
resizeListen(target, () => {
console.log("resized!");
console.log(target.offsetWidth);
});
// Unsubscribe event
resizeUnlisten(target)
```