-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransition.js
More file actions
26 lines (24 loc) · 844 Bytes
/
transition.js
File metadata and controls
26 lines (24 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
console.log(entry)
if (entry.isIntersecting) {
entry.target.classList.add('showUp');
} else {
entry.target.classList.remove('showUp');
}
});
});
const hiddenElements = document.querySelectorAll('.hiddenUp');
hiddenElements.forEach((el) => observer.observe(el));
const observer2 = new IntersectionObserver((entries2) => {
entries2.forEach((entry2) => {
console.log(entry2)
if (entry2.isIntersecting) {
entry2.target.classList.add('showLeft');
} else {
entry2.target.classList.remove('showLeft');
}
});
});
const hiddenElements2 = document.querySelectorAll('.hiddenLeft');
hiddenElements2.forEach((el2) => observer2.observe(el2));