Jump to content
GreenSock

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

onRepeat Not Firing

Go to solution Solved by Carl,

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

I'm going to assume I've missed something I'll be blushing for in a few minutes, but I've been banging my head against this and just can't work it out. All I am attempting to do, is call a function via the onRepeat callback when it is applied to a tween in a yoyo repeat state.

I've tried numerous variations of the code and can confirm that if I use onComplete, the callback works, and if I use onRepeat on the timeline rather than a tween, then that also works but that's no use to me as I need to call multiple callbacks on separate tweens.

 

I'm sure this is something very simple but for the life of me I can't work it out, if people could check out the codepen and let me know what's wrong, that would be great.

 

See the Pen VvJOMQ?editors=001 by OneManLaptop (@OneManLaptop) on CodePen

Link to comment
Share on other sites

  • Solution

thanks for the demo, very helpful.

 

onRepeat callbacks will only be applied if the tween also has a repeat property like so:

 

 

tl.to('div',2,{
    y:100, 
    ease:Elastic.easeOut.config(1.1, 0.4),
    repeat:1,
    onRepeat:testTwo
  });

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

 

you weren't telling your tweens how many times they should repeat and thus they weren't repeating and the callback had no need to execute.

an onRepeat callback on a tween is completely un-related to what happens when the timeline repeats.

 

Hopefully this helps. 

If you need some other behavior, please let us know.

  • Like 3
Link to comment
Share on other sites

Cheers Carl, that's certainly fixed it and it's prompted me to brush up on the details of the tween / timeline relationship. Thanks for your fast and thorough help as always. :)

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.
×