Jump to content
GreenSock

erikb

ticker wake issue

Go to solution Solved by GreenSock,

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

Ran into an issue this morning with the TweenMax.ticker.addEventListener.

 

Let me explain what I am doing and why it was a problem.

I was adding a tick event listener to a controller object which will send out diffs from a model to views.

(granted, this is not the primary use of your library, but as I use your library already, why not use its RAF functionality?)

 

Problem was that the initial diff object was being sent immediately, even before all of the components who need to listen for these events have been instantiated.

 

I traced the issue down to this line:

https://github.com/greensock/GreenSock-JS/blob/master/src/uncompressed/TweenMax.js#L5989

 

To work around the issue, I create a dummy tick listener and remove it right away:

    //wake up the tick engine so that our next call does not fire immediately
    var removeMeFunc = function() { console.trace( "wakey wakey"); };
    TweenMax.ticker.addEventListener('tick', removeMeFunc, this, false, 1 );
    TweenMax.ticker.removeEventListener('tick', removeMeFunc );

It would be nicer if there was an option I could set on the library to wake up the ticker without this workaround. 

 

Is there such an option or maybe a better approach?  Thanks.

 

See the Pen VaJGzo?editors=0010 by anon (@anon) on CodePen

Link to comment
Share on other sites

  • Solution

An easier workaround would be to simply call TweenLite.ticker.wake() first (no need to add a dummy listener). But yes, I see what you mean and it should be fixed in the upcoming 1.18.5 release which you can preview [uncompressed] here: https://s3-us-west-2.amazonaws.com/s.cdpn.io/16327/TweenMax-latest-beta.js

  • Like 2
Link to comment
Share on other sites

Working well for you? 

Link to comment
Share on other sites

Yes, in the pen it is working well and seems to be a good fix for that issue.  I have not been able to swap it into my larger project yet because... deadlines :-(

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