Added scroll animations for all pages

This commit is contained in:
blake committed 2025-11-20 08:51:17 -06:00
1 parent 2d758be092
commit da2a1f9519
6 files changed
+88 -40

No files matched your search

+18
View File
@@ -33,3 +33,21 @@ const headerEl = document.querySelector(".header");
btnNavEl.addEventListener("click", function () {
headerEl.classList.toggle("nav-open");
});
// Scroll Animations
document.addEventListener("DOMContentLoaded", () => {
const observerOptions = { root: null, rootMargin: "0px", threshold: 0.75 };
const onIntersection = (entries, observer) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("visible");
observer.unobserve(entry.target);
}
});
};
const observer = new IntersectionObserver(onIntersection, observerOptions);
const elementsToAnimate = document.querySelectorAll(
".animate-on-scroll, .animate-on-scroll-delay"
);
elementsToAnimate.forEach((el) => observer.observe(el));
});