window.addEventListener("click", activateVideo); // Wait until metadata loads video.addEventListener("loadedmetadata", () => { const duration = video.duration; // Smooth cinematic scroll timeline gsap.to(video, { currentTime: duration, ease: "none", scrollTrigger: { trigger: "#container", start: "top top", end: "bottom bottom", scrub: 1.5, pin: ".video-wrapper", anticipatePin: 1, // Smooth scroll rendering invalidateOnRefresh: true, } }); }); // Improve buffering + reduce lag fetch(video.src) .then(response => response.blob()) .then(blob => { const blobURL = URL.createObjectURL(blob); const currentTime = video.currentTime; video.src = blobURL; video.currentTime = currentTime + 0.01; }) .catch(err => { console.log("Video preload error:", err); }); // Optional cinematic zoom effect gsap.to(".video-background", { scale: 1.08, ease: "none", scrollTrigger: { trigger: "#container", start: "top top", end: "bottom bottom", scrub: 2 } }); });