Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created June 3, 2025 07:22
Show Gist options
  • Save Kcko/40165d45f070f71d7f9917f58d681270 to your computer and use it in GitHub Desktop.
Save Kcko/40165d45f070f71d7f9917f58d681270 to your computer and use it in GitHub Desktop.
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
}
});
});
document.querySelectorAll('.section').forEach(section => {
observer.observe(section);
});
<style>
.section {
opacity: 0;
transition: opacity 1s;
}
.section.fade-in {
opacity: 1;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment