Movatterモバイル変換


[0]ホーム

URL:


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

Commit32cabe1

Browse files
authored
Notify when element size is changed
1 parente324a05 commit32cabe1

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+
constfoo=document.getElementById("foo");
586+
587+
constobserver=newResizeObserver((entries)=> {
588+
for (let entryof entries) {
589+
constcr=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)

[8]ページ先頭

©2009-2025 Movatter.jp