We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a23d648 commit 603fba5Copy full SHA for 603fba5
README.md
@@ -525,6 +525,23 @@ const bodyBounderies = document.body.getBoundingClientRect();
525
```
526
527
528
+# Check if a node is in the viewport
529
530
+```javascript
531
+const image = document.querySelector('.animate-me');
532
+
533
+observer = new IntersectionObserver((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
+```
546
547
0 commit comments