What I wrote at first was:
function animation() {
TweenMax.to($(".Ele1"), 1, {scale: 2, fill: "rgba(255,255,255,1)", ease: Power2.easeIn, repeat: 1, yoyo: true});
TweenMax.to($(".Ele2"), 1, {scale: 2, fill: "red", ease: Power2.easeIn, repeat: 1, yoyo: true, delay: 2});
TweenMax.to($(".Ele3"), 1, {scale: 2, fill: "blue", ease: Power2.easeIn, repeat: 1, yoyo: true, delay: 3});
}
$("*").on("click", animation);
As you can see I delay each tween so that it basically seems like a timeline. I thought there must be a more elegant and simple way to achieve this.
Thats why I thought hey I should write it in a timeline. I now wrote it using mikels example like so:
var introTimeline = new TimelineMax();
function animation() {
introTimeline.to($(".Ele1"), 1, {scale: 2, fill: "rgba(255,255,255,1)", ease: Power2.easeIn, repeat: 1, yoyo: true});
introTimeline.to($(".Ele2"), 1, {scale: 2, fill: "red", ease: Power2.easeIn, repeat: 1, yoyo: true, delay: 1});
introTimeline.to($(".Ele3"), 1, {scale: 2, fill: "blue", ease: Power2.easeIn, repeat: 1, yoyo: true, delay: 2});
}
$("*").on("click", animation);
But when I do it like that the timeline repeats each of the elements 3 times … I don't understand that and don't want that to happen. Each element should just repeat once. After the animation of the first element is done the next element animates, and so on.
What I actually want is what the first code snippet does but am not sure if that is the right/most simple way to write it?
Do I really need 3 tweens that I delay one after the other? There is no shortcut method to this?
Thanks for your help guys!