Jump to content
Search Community

Return to initial state.

kevinwaterson 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

Thanks to a few guru's on this forum, I have made it to day 2 of my GSAP journey.

 

Now that I can make something happen, how do I reset it to its original state, ready to go again?

 

I have tried .reset(), as shown in the codepen, however, this does not seem to do anything.

 

Kind regards

Kevin

See the Pen zqWvKL by kevinwaterson (@kevinwaterson) on CodePen

Link to comment
Share on other sites

If you want the animation to repeat forever, you can use TweenMax instead of TweenLite and use the 'repeat:-1' property:

var tl = new TimelineMax({repeat:-1});

Or if you want it to reset and not play again, you can pause it and set the progress to 0:

var tl = new TimelineLite({onComplete:Reset});

function Reset(){
  tl.pause();
  tl.progress(0);
}

A codepen is here:

 

See the Pen ZWxWWW by craigster1991 (@craigster1991) on CodePen

 

Then to start it again simply play it:

tl.play();
  • Like 3
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...