window.__STYLEGALLERY_ASSETS__={}; gsap.utils.toArray(".comparisonSection").forEach((section) => { let tl = gsap.timeline({ scrollTrigger: { trigger: section, start: "center center", // makes the height of the scrolling (while pinning) match the width, thus the speed remains constant (vertical/horizontal) end: () => "+=" + section.offsetWidth, scrub: true, pin: true, anticipatePin: 1 }, defaults: { ease: "none" } }); tl.fromTo(section.querySelector(".afterImage"), { xPercent: 100, x: 0 }, { xPercent: 0 }).fromTo(section.querySelector(".afterImage img"), { xPercent: -100, x: 0 }, { xPercent: 0 }, 0); }); addEventListener("load", () => requestAnimationFrame(() => { ScrollTrigger.refresh(); const comparison = ScrollTrigger.getAll().find((item) => item.trigger?.matches(".comparisonSection")); if (comparison) { comparison.scroll(comparison.start + (comparison.end - comparison.start) * 0.5); ScrollTrigger.update(); } }));