Share Posted November 1, 2019 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 More sharing options...
Share Posted November 1, 2019 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now