Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
FactoryWW

useRAF and lagSmoothing on gsap object

Recommended Posts

Hello everyone, 

I searched the forum and could not find it. Can I use these methods useRAF() and lagSmoothing() on a gsap object.

I saw use-cases on tweens and timelines that developers use useRAF() and lagSmoothing(),but i need on gasp object.

I am new to GSAP animations, any help is appreciated.

The problem is next:

When i switch tab my animation stops, and i don't want that. I want to run without drop of frames in that tab.

I have created my animation over gsap object like this : 

 

this.spinAnimation = gsap.to(".spinner", {
    rotation: "+=" + this.animationSettings.normalVelocity * 1000
    duration: 1000,
    repeat: -1,
    ease: "none",
});
Link to post
Share on other sites

Hey Factory WW and welcome. Thanks for supporting GreenSock by being a Club GreenSock member! 

 

I'm not sure i'm understanding your issue. Why do you need to turn lag smoothing off or set use RAF to false?

 

You can turn off lag smoothing by using gsap.ticker.lagSmoothing(false); but this is not recommended.

  • Like 1
Link to post
Share on other sites
9 hours ago, FactoryWW said:

When i switch tab my animation stops, and i don't want that. I want to run without drop of frames in that tab.

 

That's generally considered a big "no-no" in the industry, and quite rude to the end user because it needlessly eats up CPU resources and drains battery even though the user can't see anything happening. 

 

Also, browsers throttle back their requestAnimationFrame and setTimeout() calls when a tab is inactive - it's not something GSAP does. 

 

I cannot imagine a scenario where it would be a good idea to force things to update 60 times per second while a tab is inactive. Like Zach, I'm very curious about WHY you want to do this. I'd strongly recommend against it. 

  • Like 2
Link to post
Share on other sites

ZachSaucier and GreenSock thank you. You are right it's bad idea to force inactive tab to update 60fps. I changed my logic so now 

based on some parameters I calculate where the animation should be when user returns to the page. 

 

Thank you for all your time.

Link to post
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.

×