Jump to content
Search Community

Is there a callback that fires immediately before writing properties to CSS?

peterhry test
Moderator Tag

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

No, there is no such callback but I'm very curious why you'd want that sort of thing. Can you explain? Maybe there's another solution. Offering a callback like that inside GSAP for every tween individually would have a pretty bad impact on performance. 


If you want to call a function before the GSAP engine runs all its updates (on everything for that tick), you could do something like:

TweenLite.ticker.addEventListener("tick", yourFunction, this, false, 1); //notice the last number, 1. That's the priority. The core GSAP ticker uses a priority of 0, thus this would get called before that.

See the docs at http://greensock.com/docs/#/HTML5/GSAP/TweenLite/ticker/

  • Like 3
Link to comment
Share on other sites

I don't mean to hijack the thread -- but maybe this is the right thread for an issue I am having?


Here is my situation:

My engine tweens multiple values on different javascript objects (and also receives network data which can influence tweened values).

On the ticker event (priority 1), my engine looks for differences in the current and previous state of the javascript object (using a JSON diff library).

If there is a difference, I use the values from the current javascript object to update multiple css properties on different elements.


However, it seems I am suffering from a one frame lag in my animations.  This is because the tweened values get updated on priority zero, and my ticker event does not get a chance to pick up those changes until the next RAF on priority 1.


Can I make my ticker have a negative priority?  Or can I change the priority value on my Tweens?

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