I’m trying to do image swapping via gsap.
I need to do this from image names in an array endlessly.
I do this, but it doesn’t work.
What am I doing wrong?
<div id="communication-img" >
<img loading="lazy" src="/img/chat.png"/>
</div>
const images = ['chat1','chat2','chat3']
const img = document.querySelector("#communication-img");
gsap
.timeline({
scrollTrigger: {
trigger: img,
pin: img,
}
})
.to(img, {
attr:{src:"/assets/img/chat1.png"}
})