Jump to content
Search Community

is this good practice or just unnecessary? (microing?)

jesper.landberg test
Moderator Tag

Recommended Posts

In functions that are called quite often I usually do something like this:

 

if (tl) {
  tl.kill()
}
tl = new TimelineLite()
.to(...

 

Is that better or worse than just...
 

return new TimelineLite()
.to(...


Might be a silly question just want to know if my way is more performant/optimal/worse in any way versus the below.

Link to comment
Share on other sites

Hey Jesper,

 

Clarification question: In the first option, you are killing (presumably an existing timeline) tl. In the second example, there is no tl at all - I presume the function returns to tl? Meaning something like tl = someFunc(); where someFunc returns what you have in your second example?

 

In other words, are you really just asking about the if statement in your first example vs overriding the old timeline? Meaning

 

var tl;
// ... some stuff
if (tl) {
  tl.kill()
}
tl = new TimelineLite()
.to(...

vs

var tl;
// ... some stuff
tl = new TimelineLite()
.to(...

 

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