Skip to content

Commit 32cabe1

Browse files
authored
Notify when element size is changed
1 parent e324a05 commit 32cabe1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
|25 | [Check if a string is a valid JSON](#Check-if-a-string-is-a-valid-JSON)|
3232
|26 | [getBoundingClientRect](#getBoundingClientRect)|
3333
|27 | [Check if a node is in the viewport](#Check-if-a-node-is-in-the-viewport)|
34+
|28 | [Notify when element size is changed](#Notify-when-element-size-is-changed)|
3435

3536

3637

@@ -577,4 +578,21 @@ observer.observe(image);
577578

578579
```
579580
581+
**[⬆ Back to Top](#table-of-contents)**
582+
### Notify when element size is changed
583+
see our codepen: https://codepen.io/JSsnippets/pen/dyYoYVX
584+
```javascript
585+
const foo = document.getElementById("foo");
586+
587+
const observer = new ResizeObserver((entries) => {
588+
for (let entry of entries) {
589+
const cr = entry.contentRect;
590+
console.log = `Size: ${cr.width}px X ${cr.height}px`;
591+
}
592+
});
593+
observer.observe(foo);
594+
595+
596+
```
597+
580598

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy