28 lines
875 B
JavaScript
28 lines
875 B
JavaScript
"use strict";
|
|
|
|
// Mobile navigation
|
|
const btnNavEl = document.querySelector(".btn-mobile-nav");
|
|
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.5 };
|
|
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));
|
|
});
|