Jump to content
Search Community

Watch for every time 'gsap.ticker' runs

Parrot Puppet test
Moderator Tag

Go to solution Solved by ZachSaucier,

Recommended Posts

Hey GSAP!

Looking for a way to watch if the 'gsap.ticker' has updated, any suggestions?

Read in the docs you can add your own listeners to run custom logic after each update, are there any examples available for this custom logic?


Is there a best practice for adding custom functions, for example 'gsap.ticker.onUpdate()'?
 

Thanks for your time!

See the Pen NWRyBLa?editors=0010 by GreenSock (@GreenSock) on CodePen

Link to comment
Share on other sites

Hello @GreenSock,

 

Sorry for the confusion, hope this helps clear up the question

In the docs for the gsap ticker is says the following 'You can add your own listener(s) to run custom logic after each update (great for game developers)'
Link: https://greensock.com/docs/v3/GSAP/gsap.ticker

 

I was hoping to get some help on how to attached listeners for custom logic onto the ticker, for example is there a way to check if the tick has updated or if there is an error during the tick event?

Please let me know if this helps,
Thank you

Link to comment
Share on other sites

  • Solution
7 hours ago, jparrott said:

I was hoping to get some help on how to attached listeners for custom logic onto the ticker

You use the gsap.ticker.add() method for that :) 

 

7 hours ago, jparrott said:

is there a way to check if the tick has updated

Once you have added a function to GSAP's ticker it runs every time the ticker updates.

 

7 hours ago, jparrott said:

if there is an error during the tick event

There is no general error listener for the event, no. However you can wrap whatever code you write in your own try catch blocks. 

 

Perhaps it'd be helpful to share with us what you're trying to accomplish.

 

Edit: I'm betting you're the same person that asked this on StackOverflow. I think the issue boils down to a misunderstanding of how this and/or arrow functions work :) 

  • Like 1
Link to comment
Share on other sites

The ticker fires regardless - that warning is just a warning, not an error that stops the ticker or something. Maybe it'd help if you explained the reasoning behind your question. Are you looking for a way to get notified if ANY tween EVER is poorly written such that it's attempting to animate a property that doesn't exist? If so, no, doing something like that would really hurt performance and we're performance nuts around here :)

 

Practically speaking, though, that wouldn't even be very useful because you'd want to catch those errors in development. If you're writing tweens incorrectly (to animate non-existent properties), those should be fixed before you push your project live anyway. See what I mean? And regardless, none of that impacts the ticker itself which keeps on chuggin'. 

 

Happy tweening!

  • 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.
×
×
  • Create New...