Jump to content
Search Community

Fire function on final timeline repeat?

curtiswiens test
Moderator Tag

Recommended Posts

Hey, 

 

I couldn't find onRepeatComplete anywhere, which is probably why it didn't work. You most likely meant onRepeat.

But maybe an onComplete is sufficient as well, if you are indeed in your last repeat (according to the title), so you can avoid the variable incrementing.

 

Link to comment
Share on other sites

Normally it should only be triggered at the end, maybe some other little error slipped in there, but at this point it's hard to tell. 

If the problem continues then you should definitely create a minimal codepen so we can have a better look at it.

 

From the documentation:

//create the timeline that repeats 3 times with 1 second between each repeat and then call myFunction() when it completes
var tl = gsap.timeline({repeat: 3, repeatDelay: 1, onComplete: myFunction});

 

Link to comment
Share on other sites

Hi @curtiswiens,

 

We got you covered ;), what you need is the iteration method: 

https://greensock.com/docs/v3/GSAP/Timeline/iteration()

 

Just plug that on the onRepeat callback to check if this is the last iteration based on the number of repeats you have. Here is a live example:

See the Pen yLjrGra by GreenSock (@GreenSock) on CodePen

 

Let us know if you have any other question.

 

Happy Tweening!

  • Like 2
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.
×
×
  • Create New...