Jump to content
Search Community

Performance of two timeline rather then one.

rgfx test
Moderator Tag

Go to solution Solved by GreenSock,

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

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

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.

:)

  • Like 4
Link to comment
Share on other sites

  • Solution

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!

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