@juggle/resize-observer
Advanced tools
Comparing version 0.4.1 to 0.4.2
{ | ||
"name": "@juggle/resize-observer", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "ResizeObserver - Based on the official draft specification", | ||
@@ -5,0 +5,0 @@ "main": "./lib/ResizeObserver.js", |
@@ -8,5 +8,7 @@ # ResizeObserver | ||
A polyfill entirely based on the current **ResizeObserver** [Draft Specification](https://wicg.github.io/ResizeObserver). | ||
A polyfill/ponyfill entirely based on the current **ResizeObserver** [Draft Specification](https://wicg.github.io/ResizeObserver). | ||
This library observes elements and dispatches notifications when dimensions change. No polling of the DOM is required, except for when animations or transitions are active, keeping CPU and power consumption minimal. | ||
## Installation | ||
@@ -21,7 +23,10 @@ ``` shell | ||
const resizeObserver = new ResizeObserver((entries, observer) => { | ||
console.log('Something has resized!'); | ||
const ro = new ResizeObserver((entries, observer) => { | ||
console.log('Body has resized!'); | ||
observer.disconnect(); // Stop observing | ||
}); | ||
ro.observe(document.body); // Watch dimension changes on body | ||
``` | ||
This will always use the polyfilled version of **ResizeObserver**, even if the browser supports **ResizeObserver** natively. | ||
This will use the ponyfilled version of **ResizeObserver**, even if the browser supports **ResizeObserver** natively. | ||
@@ -38,3 +43,4 @@ | ||
const resizeObserver = new ResizeObserver((entries, observer) => { | ||
// Uses native or polyfill, depending on browser support | ||
const ro = new ResizeObserver((entries, observer) => { | ||
console.log('Something has resized!'); | ||
@@ -41,0 +47,0 @@ }); |
28002
56