14 lines
379 B
JavaScript
14 lines
379 B
JavaScript
|
const observer = new IntersectionObserver((entries) => {
|
||
|
entries.forEach((entry) => {
|
||
|
if(entry.isIntersecting){
|
||
|
entry.target.classList.add('show');
|
||
|
} else {
|
||
|
entry.target.classList.remove('show');
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
});
|
||
|
|
||
|
const hiddenElements = document.querySelectorAll('.hidden');
|
||
|
hiddenElements.forEach((el) => observer.observe(el));
|