Jump to content
Search Community

reuse a tweenlite?

erikb 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

In a project, I have only one tweenlite instance tweening at one time.

 

Each time, the tweenlite instance is tweening different values.

 

The instance is assigned to a class variable.

 

Currently, I instantiate a new Tweenlite instance every time, assigning it to that one instance every time.

 

I am wondering if it would be better to 'gut' the existing tweenlite instance and reuse it?  Is there a best practice for doing this?

 

I looked at kill(), but am not sure where to go from there.

 

 

Link to comment
Share on other sites

I've looked into instance reusage and pools, etc. and I found that the cost of "cleaning" the old object and re-populating it with new values is often more expensive than just creating a new instance. Add to that the extra kb it'd cost inside the engine if we tried to accommodate that kind of usage, and it just doesn't make much sense for us to do. 

 

Remember, you don't have to worry about setting things to garbage collect manually with GSAP - it handles all that under the hood (assuming you don't retain references to instances in your app and never release them, but that's pretty uncommon). 

 

So ultimately my advice is: just keep creating new instances like you were - that's the best practice. 

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