Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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)

AltStyle によって変換されたページ (->オリジナル) /