Hi,
I just saw the infinite slider of GSAP, but I want to add another functionality, so when the user scrolls, the slides are snapping in view.
I added the ScrollTrigger functionality, but it seems it not working and I can't find the issue by myself.
So does anyone know how I can fix the issue, so the slider can also used with scroll, similar to how the prev and next buttons work?
// Use ScrollTrigger to control the slider with scroll
gsap.to(wrapper, {
scrollTrigger: {
trigger: wrapper,
start: "top top",
end: "bottom bottom",
scrub: 1, // Controls the sensitivity of the scroll
},
onUpdate: (scrollTrigger) => {
const progress = scrollTrigger.progress;
const totalDuration = loop.totalDuration();
const time = progress * totalDuration;
loop.tweenTo(time);
},
});