-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
24 lines (22 loc) · 885 Bytes
/
app.js
File metadata and controls
24 lines (22 loc) · 885 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
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) =>{
console.log(entry)
if(entry.isIntersecting) {
if(entry.target.classList.contains('hidden-right')){
entry.target.classList.add('shown-right');
}else{
entry.target.classList.add('shown-left');
}
}else {
if(entry.target.classList.contains('hidden-right')){
entry.target.classList.remove('shown-right');
}else{
entry.target.classList.remove('shown-left');
}
}
});
});
const hiddenRightElements = document.querySelectorAll('.hidden-right');
hiddenRightElements.forEach((el) => observer.observe(el));
const hiddenLeftElements = document.querySelectorAll('.hidden-left');
hiddenLeftElements.forEach((el) => observer.observe(el));