ok. If I want to make a universal animation and animate different objects with it, how do I do that?
function animate(elem) {
gsap.timeline({ease: "power1.inOut",repeat: 1,yoyo: true,repeatDelay: 3})
.to(elem, { opacity: 0, scale: 0.5, transformOrigin: "center", duration: 0.3 })
.set(elem, { text: { value: "ДОБАВЛЕНО", delimeter: " " } })
.to(elem, { opacity: 1, scale: 1, transformOrigin: "center", duration: 0.3 }, "<")
}
I just assumed that it would be convenient to do it this way: declare a "tween" and pass in Restart() (or another action) the object to be animated. I mean something like this:
const tl = gsap.timeline({ease: "power1.inOut",paused: true,repeat: 1,yoyo: true,repeatDelay: 3})
.to(?, { opacity: 0, scale: 0.5, transformOrigin: "center", duration: 0.3 })
.set(?, { text: { value: "ДОБАВЛЕНО", delimeter: " " } })
.to(?, { opacity: 1, scale: 1, transformOrigin: "center", duration: 0.3 });
tl.restart({object: ".target"});
p.s.
And thank you so much for the solution. I had completely forgotten about the ".set".