1.0.0 • Published 2 years ago

sole-resize-observer v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Sole Resize Observer

Installation

Install via NPM.

npm install sole-resize-observer

Information

The recommended pattern is to observe all elements using a single ResizeObserver. This library makes it easier.

import { soleResizeObserver } from "sole-resize-observer";

const callback = ()=>{
	console.log("The element's height is:", element.clientHeight);
}

soleResizeObserver.addListener(element, callback);

soleResizeObserver.removeListener(element, callback)

Like the built-in ResizeObserver, observations are tied to the element's life cycle, thus calling removeListener is usually not necessary.

License

MIT License All files can be used for commercial or non-commercial purposes. Do not resell. Attribution is appreciated but not due.