In this pen I have a timeline. It has 4 '.to' statements, representing two pairs providing different animations where the card on the right moves, then moves back to its starting point.
As part of a wider project, I'd like to be able to pass in a movement, or one of these pairs, as a variable. What I'm trying looks a little like this:
const variable = ` <-- trying using backticks
.to(".card1", {
x: "-60px",
duration: 0.5,
ease: "power4.inOut"
})
.to(".card1", {
x: "0px",
duration: 1,
ease: "power2.inOut"
})`
tl
.variable <-- PASSING THIS IN DOESN'T WORK
.to(".card1", {
rotation: "-45deg",
duration: 0.2,
ease: "power1.inOut"
})
.to(".card1", {
rotation: "360deg",
duration: 1,
delay: 0.2,
ease: "power1.inOut"
});
I'm sure there's an easy solution here.
I guess the next question i'll have is how you would pass in these variables conditionally... like can you embed a ternary into the chain?
Thanks!!