Jump to content
Search Community

Tl works twice

Alina P test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi! I have problem. If the function immediately receives action === play, the animation works perfectly. If pause first and then play, then tlClientsTimeline works twice, and only then the callback starts. What is my mistake?

 

What should be: tlClientsTimeline ends, tab switches, tlClientsChat begins. At the first launch, the function works correctly, but if you change the slide and then restart tl, it works twice.

See the Pen MWdyZyb by aodxfaionn (@aodxfaionn) on CodePen

Link to comment
Share on other sites

Without a minimal demo, it's very difficult to troubleshoot; Would you please provide a very simple CodePen or Stackblitz that illustrates the issue? You didn't share the other code where the timelines are created, and there may be other things in your code that impacts things. When you only share this small excerpt of the code, it doesn't really allow us to troubleshoot effectively.

 

If you're using React, make sure you're using the useGSAP() hook. See https://gsap.com/react

 

See the Pen aYYOdN by GreenSock (@GreenSock) on CodePen

that loads all the plugins. Just click "fork" at the bottom right and make your minimal demo

 

Using a framework/library like React, Vue, Next, etc.? 

CodePen isn't always ideal for these tools, so here are some Stackblitz starter templates that you can fork and import the gsap-trial NPM package for using any of the bonus plugins: 

Once we see an isolated demo, we'll do our best to jump in and help with your GSAP-specific questions. 

Link to comment
Share on other sites

  • Solution

Oh, it looks like a logic problem in your code - you're recreating the animations EVERY time animationClients() is called. And you're creating them AFTER you run your pause/play logic. 

 

I assume you meant to create the animations once (outside that function), and then just play/pause them as necessary, rather than creating them over and over again inside that toggling function. 

 

If you still need help, please make sure you only include a minimal demo - your demo had 400+ lines of code. That makes it very cumbersome to troubleshoot and it's beyond the scope of help we can provide here. Just recreate the problem in the simplest form possible. No need to include your real project. Just some simple colored <div> elements is fine. 

Link to comment
Share on other sites

7 minutes ago, GreenSock said:

Oh, it looks like a logic problem in your code - you're recreating the animations EVERY time animationClients() is called. And you're creating them AFTER you run your pause/play logic. 

 

I assume you meant to create the animations once (outside that function), and then just play/pause them as necessary, rather than creating them over and over again inside that toggling function. 

 

If you still need help, please make sure you only include a minimal demo - your demo had 400+ lines of code. That makes it very cumbersome to troubleshoot and it's beyond the scope of help we can provide here. Just recreate the problem in the simplest form possible. No need to include your real project. Just some simple colored <div> elements is fine. 

Yes, it`s true. I fixed my bug. Thanks!

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