Jump to content
Search Community

Gsap 3 - return animation to start without delay

Lichay test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Gsap 3 - return animation to start without delay

How can I return my animation to start point without any animation after the effect? 

 

on example my h1 go right stay there 1-2 sec and back to left - How can I eliminate that delay

and How can I return immediately to start point without animation 

Thanks for you help!!

 

See the Pen NWRZEKe by lichaytiram (@lichaytiram) on CodePen

Link to comment
Share on other sites

  • Solution

It isn't staying there for 1-2 seconds in your demo - it's an illusion caused by the fact that you're using a "power4.out" ease which makes it slow WAY down at the end. If you change that ease to "none", for example, you'll see the change in direction is immediate. 

 

To make it jump back to the very start of the animation once it completes, you can use an onComplete to basically "rewind" it like this: 

See the Pen 43a85e285303a5e8f47ae9b9090f7ca2?editors=0010 by GreenSock (@GreenSock) on CodePen

 

There are actually a bunch of ways you could do it, but I don't want to overcomplicate things by listing them all out. 

 

Does that clear things up? 

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

To add to @GreenSock's excellent advice...

 

The ease curve (Power4) you chose gets very flat at the end making the rate of change so small that it appears the animation has delayed.

 

This video should help you understand how ease curves work

 

If you want to reset the position of the h1 after it moves to the right, this is a great time to use a timeline. A timeline allows you to sequence multiple animations. 

 

With a timeline you can add a set() to a timeline to set the h1's position back to 0

See the Pen rNMEoNz?editors=1010 by snorkltv (@snorkltv) on CodePen

 

Obviously GreenSock's suggestion works great with just one tween. Being that the GSAP API is so robust and packed with features there are often many ways to do the same thing.

 

 

 

  • Like 3
  • Thanks 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.
×
×
  • Create New...