Hi There,
This works great thank you so much. Can we also add next/previous arrows as well? If any one can add that as well that would be awesome. I tried to add it but when I double click the arrow it doesn't calculate the rotation accurately.
leftArrow.addEventListener("click", (event) => {
const myTimeout = setTimeout(() => rotateWheel(1), 500);
});
rightArrow.addEventListener("click", (event) => {
const myTimeout = setTimeout(() => rotateWheel(-1), 500);
});
function rotateWheel(direction) {
const totalImages = images.length;
const angle = (360 / totalImages) * direction;
const currentRotation = gsap.getProperty(".wheel", "rotation");
const newRotation = currentRotation + angle;
console.log('testtttt', images.length);
gsap.to(".wheel", {
rotation: newRotation,
duration: images.length,
ease: "power1.inOut",
scrollTrigger: {
start: 0,
end: "max",
scrub: 1,
snap: 1 / images.length,
invalidateOnRefresh: true
}
});
}
Thank you,
Sameer