// lenis smooth scroll init const lenis = new Lenis(); function raf(time) { lenis.raf(time); requestAnimationFrame(raf); } requestAnimationFrame(raf); // in view detect function for elements animation !(function () { const blocks = document.querySelectorAll(".block-01 .logo, .block-01 .headline, h2, .block-02 .swiper, .block-03 .col a, .block-04 .col-left,.block-04 h2,.block-04 .swiper, .block-05 h2, .block-05 .card, .block-06 h2, .block-06 p, .block-06 .field, .block-06 .submit, .block-07 .col"); [].forEach.call(blocks, ($item) => { function onScroll() { let delta = $item.getBoundingClientRect().top - window.innerHeight <= ($item.offsetHeight * -1) / 4 && !$item.classList.contains("in-view"); if (delta) { setTimeout(() => { $item.classList.remove("in-view-detect"); $item.classList.add("in-view"); }, 400); } } onScroll(); lenis.on("scroll", (e) => { onScroll(); }); }); })(); // swiper sliders if (document.querySelector(".reviews-slider")) { const reviewsSwiper = new Swiper(".reviews-slider", { loop: true, speed: 1000, spaceBetween: 0, autoplay: { delay: 5000, }, pagination: { el: ".reviews-slider .swiper-pagination", clickable: true, }, }); } if (document.querySelector(".dates-slider")) { const datesSwiper = new Swiper(".dates-slider", { speed: 500, spaceBetween: 0, pagination: { el: ".dates-slider .swiper-pagination", clickable: true, }, }); } // navigation const nav = document.querySelector(".navigation"); function navClose() { nav.classList.remove("active"); const scrollY = document.body.style.top; document.querySelector("body").removeAttribute("style"); window.scrollTo(0, parseInt(scrollY || "0") * -1); } function navOpen() { nav.classList.add("active"); const scrollY = window.scrollY; document.querySelector("body").style.position = "fixed"; document.querySelector("body").style.top = -scrollY + "px"; } document.querySelector(".navbar-toggler").addEventListener("click", function () { if (nav.classList.contains("active")) { navClose(); } else { navOpen(); } }); document.querySelectorAll(".block-07 a").forEach((el) => { el.addEventListener("click", function (e) { if (nav.classList.contains("active")) { navClose(); } if (this.classList.contains("anchor-link")) { e.preventDefault(); let dest = document.querySelector(this.hash); setTimeout(() => { lenis.scrollTo(dest, { duration: 1 }); }, 500); } }); });