window.addEventListener("load", function () { // Intro overlay: take it out of rendering while it is fully transparent, // bring it back as soon as an interaction fades it in again. var loader = document.querySelector(".loader"); if (loader) { var syncLoader = function () { var transparent = parseFloat(getComputedStyle(loader).opacity) === 0; if (transparent && loader.style.display !== "none") { loader.style.display = "none"; } else if (!transparent && loader.style.display === "none") { loader.style.display = ""; } }; new MutationObserver(syncLoader).observe(loader, { attributes: true, attributeFilter: ["class", "style"], }); loader.addEventListener("transitionend", syncLoader); [1000, 3000, 6000].forEach(function (ms) { setTimeout(syncLoader, ms); }); } if (!("IntersectionObserver" in window)) return; // Looping background/cover videos: only play while on screen. var videoObserver = new IntersectionObserver( function (entries) { entries.forEach(function (entry) { var video = entry.target; if (entry.isIntersecting) { var playing = video.play(); if (playing && playing.catch) playing.catch(function () {}); } else if (!video.paused) { video.pause(); } }); }, { rootMargin: "200px 0px" }, ); document.querySelectorAll("video[autoplay]").forEach(function (video) { videoObserver.observe(video); }); // Footer email marquee: pause while off screen. setTimeout(function () { var marquee = document.querySelector(".cta-bottom"); if (!marquee || !window.gsap) return; var timelines = []; gsap.getTweensOf(".cta-bottom-part").forEach(function (tween) { var tl = tween.parent; if (tl && tl !== gsap.globalTimeline && timelines.indexOf(tl) === -1) { timelines.push(tl); } }); if (!timelines.length) return; new IntersectionObserver(function (entries) { entries.forEach(function (entry) { timelines.forEach(function (tl) { if (entry.isIntersecting) tl.resume(); else tl.pause(); }); }); }).observe(marquee); }, 1000); });