Hi,
In the demo, I want to change the text for each time color changes.
I used to do this with Set or with an onComplete
I´m trying to do it with .add but target is wrong ("target message not found")
function changeText(arr) {
gsap.to("#message", { text: changeText(messages) });
}
var tl = gsap.timeline({ repeat: -1 });
colors.forEach((color) => {
tl.to("#message", { xPercent: -50, left: "50%", duration: 0, delay: 0 })
.to("#bg", { backgroundColor: color.dark, duration: 1, delay: 3 })
.to("#message", { color: color.light, duration: 1, delay: 0 })
.add(generateText);
});
function generateText() {
gsap.to("message", { text: changeText(messages) });
}
let counter = 0;
function changeText(arr) {
console.log("dentro");
counter = counter + 1;
return messages[counter].title;
}
Any help is welcome