-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (20 loc) · 715 Bytes
/
Copy pathscript.js
File metadata and controls
23 lines (20 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if ('IntersectionObserver' in window) {
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
console.log(entry);
if (entry.isIntersecting) {
entry.target.classList.add('show');
} else {
entry.target.classList.remove('show');
}
});
});
const hiddenElements = document.querySelectorAll('.hidden');
if (hiddenElements.length > 0) {
hiddenElements.forEach((el) => observer.observe(el));
} else {
console.warn('No elements with the class "hidden" found.');
}
} else {
console.error('Intersection Observer is not supported in this browser.');
}