Jump to content
Search Community

TweenMax.ticker frames per second

Parrot Puppet 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

Hello GSAP,

 

Looking for a way to return the actual ticks per second and display on the browser so I know when the animations are getting heavy.

 

    function addListeners () {
        TweenMax.ticker.useRAF(false);
        TweenMax.ticker.addEventListener("tick", handleTick);
        TweenMax.ticker.fps(60);
    }

 

   function handleTick(e){
         fps.innerHTML = Math.round(TweenMax.ticker.FPS) + " fps";
    }

Link to comment
Share on other sites

Yep, @PointC pointed to a useful thread that shows all the logic, but if you just want to use simple GSAP-specific code that, this should be a rough approximation: 

 

var fps = TweenLite.ticker.frame / TweenLite.ticker.time;

 

Just remember that it'll usually be less than 60 because the "time" starts measuring the moment the JS loads, but there's typically a bunch of other tasks that the browser must do initially (like reading/parsing HTML, rendering the page, subloading other files, etc., etc.) so that first few seconds it's quite likely that there will be a lower FPS. And this technique measures the OVERALL performance, not the moment-by-moment performance. If you need something like that, use one of the techniques discussed in that other thread. 

 

Happy tweening!

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