Jump to content
Search Community

ticker wake issue

erikb test
Moderator Tag

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

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