(() => { "use strict"; const root = document.documentElement; const loader = document.getElementById("page-loader"); const pageContent = document.querySelector("body > main"); if (!loader) { return; } const isSP = window.matchMedia("(max-width: 768px)").matches; const fadeStartTime = 4000; const fadeDuration = 2000; let isFinished = false; root.classList.add("is-page-loading"); const updateRevealOrigin = () => { if (!pageContent) { return; } const contentRect = pageContent.getBoundingClientRect(); const centerX = (window.innerWidth / 2) - contentRect.left; const centerY = (window.innerHeight / 2) - contentRect.top; pageContent.style.setProperty("--page-reveal-x", `${centerX}px`); pageContent.style.setProperty("--page-reveal-y", `${centerY}px`); }; updateRevealOrigin(); window.addEventListener("pageshow", updateRevealOrigin, { once: true }); window.addEventListener("resize", updateRevealOrigin); const removeLoader = () => { loader.remove(); }; const finishLoading = () => { if (isFinished) { return; } isFinished = true; updateRevealOrigin(); root.classList.add("is-page-revealing"); loader.setAttribute("aria-hidden", "true"); loader.classList.add("is-page-loader-hidden"); window.setTimeout(() => { root.classList.remove("is-page-loading"); root.classList.remove("is-page-revealing"); window.removeEventListener("resize", updateRevealOrigin); removeLoader(); }, fadeDuration); }; // Both SP and PC reveal over 2s after 4s, finishing at 6s. window.setTimeout(finishLoading, fadeStartTime); })();