Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Kikovich

Repeating Timeline question

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

I'm trying to make a very basic animation: two labels enter the banner from the left side, stop on a specific position and then fade out. (See Codepen)

This animation should repeat three times - but the third time without fadeout. How can I create this simple animation?

Thx in advance,

Chris

 

 

See the Pen MwdmWz by anon (@anon) on CodePen

Link to comment
Share on other sites

Hi and welcome to the GreenSock forums?

 

Thanks for the simple demo. Very helpful.

 

I suggest adding a callback to the timeline right before the end fade that checks to see how many times the timeline has played. If you reach the max number of plays, pause the timeline or else keep playing.

 

timeLine = new TimelineMax({
 repeat: -1
});
 
timeLine.add(aniBlueBox, "+=1");
timeLine.add(aniWhiteBox);
timeLine.add("end");
timeLine.call(checkPlayCount);
timeLine.add(aniFade, "end+=3");
timeLine.timeScale(3)
  


var playCount = 0;
var maxPlayCount = 3;


function checkPlayCount(){
  if(++playCount == maxPlayCount) {
    timeLine.pause("end")
  }
}

http://codepen.io/GreenSock/pen/KpLmmb?editors=001

  • Like 4
Link to comment
Share on other sites

Thank you very much Carl! Simple question, simple answer :D

But I'm new to this - and was trying a 1.000 things and didn't get it to work!

Thx again!

Link to comment
Share on other sites

You're welcome. 

I'm sure plenty of others will need to do something just like this. Glad you asked.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×