Jump to content
Search Community

Whether manual release is required in vuejs

Ryan Lee test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi!

As the title says, I want to know whether we need to release manually to achieve the purpose of performance optimization.

for example:

Some animations are set in component A, and I guess there are some monitoring methods will be implemented. Like: onresize or onscroll...

When we leave or destroy components, do these monitors still exist? Or do we need to destroy it manually when we leave?

Like vuejs:

destroyed() {
  // gsap.clear() or gsap.destroy()  any methods like this ?
}

 

Link to comment
Share on other sites

  • Solution

In the vast majority of cases you don't need to worry about killing things manually, no. When an animation finishes running, it is made eligible for garbage collection from the core. The only exceptions I can think of are: 

  • If you have an infinitely repeating tween
  • ScrollTriggers

You can kill all the ScrollTriggers on a page like this:

ScrollTrigger.getAll().forEach(t => t.kill())

You can clear all animations an delayedCalls like this:

gsap.globalTimeline.clear();

But again, that's only useful if you're dynamically loading new content and you want to flush all the old stuff WITHOUT the browser navigating to a new address. 

 

Does that answer your question?

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