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

Commit603fba5

Browse files
authored
check if a node is in the viewport
1 parenta23d648 commit603fba5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

‎README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,23 @@ const bodyBounderies = document.body.getBoundingClientRect();
525525
```
526526
527527
528+
# Check if a node is in the viewport
528529
530+
```javascript
531+
constimage=document.querySelector('.animate-me');
532+
533+
observer=newIntersectionObserver((entries)=> {
534+
const [myImg ]= entries;
535+
if (myImg.intersectionRatio>0) {
536+
myImg.target.classList.add('fancy');
537+
}else {
538+
myImg.target.classList.remove('fancy');
539+
}
540+
});
541+
542+
543+
observer.observe(image);
544+
545+
```
529546
530547

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp