Modern UI/UX Interaction Example
Sarah Drasner, a world-renowned web developer and educator.
Published April 12, 2022
Scroll-triggered animations using IntersectionObserver API.
Improves engagement and modernizes web experiences.
// script.js
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('show');
}
});
});
document.querySelectorAll('.fade-in').forEach(el => observer.observe(el));