Share Posted February 22, 2017 I find it easier sometimes to create two timelines rather then one for complex animations. I know I can make one timeline out of it, but my head is spinning as it is. Wondering if there is a performance hit of any sort using two timeline instead of one. I will have two object moving at once regardless. Thanks Link to comment Share on other sites More sharing options...
Share Posted February 22, 2017 If your animations are getting complex and hard to manage, it sounds like the perfect time to start nesting your animations in a master timeline. You'll find it easier to work on small segments and move individual pieces around a master timeline. The code looks like this: function part1() { var tl = new TimelineMax(); tl.to( element, 1, { } ); return tl; } function part2() { var tl = new TimelineMax(); tl.to( element, 1, { } ); return tl; } var masterTimeline = new TimelineMax(); masterTimeline .add( part1() ) .add( part2() ); Here's a simple CodePen with the basic mechanics and a position parameter added to the nested timelines. See the Pen ZLxdXz by PointC (@PointC) on CodePen Hopefully that helps. Happy tweening. 4 Link to comment Share on other sites More sharing options...
Author Share Posted February 22, 2017 Right, so there is a performance difference between two timelines vs one? Link to comment Share on other sites More sharing options...
Share Posted February 22, 2017 Nah, performance-wise it's almost the same. I guess technically it's an extra function call if you nest it, but you'd never notice any real-world difference unless maybe you're nesting things hundreds of levels deep and there are thousands and thousands of simultaneous tweens. Actually, in some cases nesting can actually improve performance. Happy tweening! 4 Link to comment Share on other sites More sharing options...
Author Share Posted February 23, 2017 Thats what I thought. Thanks Jack. 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