Skip to content

Commit

Permalink
feat: scroll window element observer
Browse files Browse the repository at this point in the history
  • Loading branch information
emekauja committed Feb 29, 2024
1 parent 2cc9c7b commit e350475
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// function app() {
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
console.log('entry ==>', entry);
if (entry.isIntersecting) {
entry.target.classList.add('animate');
}
});
});

const hiddenElements = document.querySelectorAll('.inanimate');
hiddenElements.forEach((element) => observer.observe(element));
// }

// app();

0 comments on commit e350475

Please sign in to comment.