Jump to content
Search Community

delay() doesn't work second time

Voo 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

Hi Voo,

 

.delay() can be a bit misleading – when you call blue.play().delay(0.5), you set the initial delay for blue to 0.5s. When you call it again later on, you set that initial delay to 0.5s again, which doesn't do anything because it was already set to that value.

 

The reason it doesn't wait again is because .delay() is only for the initial delay, that is the time before the animation plays for the first time. It is not part of the animation itself (which is why it isn't affected by the animation's timeScale). If you reverse the animation and then play it again, it will go to its starting position, but that initial delay is already 'gone'.

 

If you want a tween that always starts after 0.5s, an easy way would be to use the position parameter like this:

blue.to('.blue', 1, {x: '500%', ease: Power4.easeIn}, 0.5);

 

If you want to add a waiting period at the end of an animation, you can add an empty tween like this: 

red.to({}, 0.5, {});

(or add a label)

 

That way, when you reverse the animation, it will first "tween" nothing for 0.5s, then proceed with the tween that comes before that.

 

(PS: this is a very minor thing, but maybe not everyone is a guy here ;) )

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