useLayoutEffect(() => {
const ctx = gsap.context(() => {
const panels = gsap.utils.toArray(".panel");
gsap.to(panels, {
xPercent: -100 * (panels.length - 1),
ease: "none",
scrollTrigger: {
trigger: slider.current,
pin: true,
scrub: 1,
snap: 1 / (panels.length - 1),
end: () => "+=" + slider.current.offsetWidth,
markers: false,
}
});
}, component);
return () => ctx.revert();
});