Jump to content


Conditional repeat of tweens

Recommended Posts

Hi guys,


Trying to get a conditional 'repeat' happening with a stagger animation.


I want to be able to set a boolean variable (cloudsOn) and if this is true, certain tweens will replay. If it is off, the tweens will not replay.


I've managed to get this working in other more custom javascript ways (thanks to help on this forum), but wanted to see if there was a simple way using a stagger loop and onComplete to get this happening.


I will post a CodePen but this may be enough to check if it is a simple fix. Thanks.

// five .cloud elements in my SVG
var cloud = document.querySelectorAll('.cloud');

var tlClouds = new TimelineMax();

var cloudsOn = true;

var cloudCheck = function(tween){
    if (cloudsOn){
        console.log(tween); // Successfully logs the individual tweens of the stagger, targeting individual .clouds.

.staggerTo(cloud, 2, {
        x: [-400, -200, 0, 300]
    onComplete: cloudCheck,
    onCompleteParams: ['{self}']
}, 0.2)
Link to comment
Share on other sites

Hi spacewindow :)


actually you can't do that in this way ,Timeline control its childs playhead , so you can't seek,pause,play or restart timeline child separately .

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