Jump to content
Search Community

Trying to repeat a new animation onComplete

Zaperela test
Moderator Tag

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

Hey There,

 

This is my first post here at GSAP forums. Loving the tool so far! I'm a designer that's learning JS, so my code is probably going to be meh. 

 

I'm having a little problem though, I have the animation running just fine, but wanted the three circles to continue to spin after the main animation. So I used onComplete to run another function that has the continued animation inside. It seems to work "kind of". The problem is only one of the circles continues to spin. It looks like it tries at first and then gives up and rotates just one circle. What am I doing wrong (I'm sure a few things)?

 

Any help or tips would be much appreciated.

See the Pen vRXymV by Zaperela (@Zaperela) on CodePen

  • Thanks 1
Link to comment
Share on other sites

Hi @Zaperela:)

 

Welcome to the forum.

 

The reason your demo wasn't (kinda sorta) working was the onComplete was in the wrong spot and being called three times. It is a bit confusing, but for stagger tweens the onCompleteAll goes after the stagger number. So what you were seeing was the infinite circle repeat timeline starting before it should have which caused an overwrite. 

 

More info in the stagger docs:

https://greensock.com/docs/TweenMax/static.staggerFrom()

 

In addition to @Shaun Gorneau's demo or moving that onComplete call on the stagger, you could also move the onComplete to the vars of the cs timeline. Lots of options.

 

See the Pen eMdvop by PointC (@PointC) on CodePen

 

See the Pen YaGNYP by PointC (@PointC) on CodePen

 

 

Hopefully that helps. Happy tweening and welcome aboard.

:)

 

 

  • Like 5
Link to comment
Share on other sites

Slight clarification for anyone following along. I don't want to confuse anyone.

 

On a regular tween the onCompleteAll goes after the stagger number.

TweenMax.staggerFrom( targets:Array, duration:Number, vars:Object, stagger:Number, onCompleteAll:Function, onCompleteAllParams:Array, onCompleteAllScope:* ) 

 

For a timeline, the onCompleteAll goes after the stagger and position:

.staggerFrom( targets:Array, duration:Number, vars:Object, stagger:Number, position:*, onCompleteAll:Function, onCompleteAllParams:Array, onCompleteScope:* ) 

 

Happy tweening.

:)

 


 

  • Like 4
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...