Jump to content
Search Community

Rendering Problem: add() and addCallback() are pausing the execution of the timeline

Maxime test
Moderator Tag

Go to solution Solved by Maxime,

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

tl.to($obj, speed, { 
 y: '40'
});

tl.addLabel('label');

tl.addCallback(function() {	
 playSound();
}, 'label+=.15');

tl.addCallback(function() {	
 playSound();
}, 'label+=.25');

For me, the timeline WAIT the execution of call()/addCallback().

 

Can someone explain me why the timeline is paused (or not rendered) when I use add() and addCallback()?

 

The best would be to have a running timeline (not disturbed by callbacks).

 

Using a timeline is give the possibility to insert small function at the right place without doing the non maintainable way with setTimeout({}, 200)..

 

Attempt: Wrap the callback function in a setTimeout(playSound, 0). Not working :(

 

Pen: 

See the Pen GgrRae by magister (@magister) on CodePen

Link to comment
Share on other sites

Ok, so what's in playSound then? It will block all other JavaScript execution (including GSAP) until it's completed. add() and addCallback() aren't pausing the timeline, it's playSound that is taking too long (too many loops perhaps?).
 
This isn't a GSAP specific issue by the way - all JavaScript is single threaded. There's not a lot more we can say about a function we know nothing about.

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