Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
phillip_vale

Resume a paused timeline from another timeline

Recommended Posts

Hi,

 

I am trying to work out best practice to pause another play another timeline.

 

I have included 2 attempts with the first commented out.

 

Ideally i would like it to run so that in the sequence of the first timeline (tl1) it resumes the paused timeline (tl2).

 

I'm not sure if this means that an onComplete need to be added or whether it can just be a command in the timeline.

 

e.g.

 

.from("object", 1, {})...

.from("object", 1, {})...

.resume("tl2")

.from("object", 1, {})...

 

Sorry if the syntax is incorrect just trying to explain my problem.

 

Any help is appreciated.

 

Thank you,

 

Phil

See the Pen rLVMaB?editors=1010 by phillip_vale (@phillip_vale) on CodePen

Link to comment
Share on other sites

kind of hard to understand, but it looks like you are close but you only created one tween for #moving... nothing for #move.

maybe this will help:

http://codepen.io/GreenSock/pen/RRPKYK?editors=1010

 

However this really doesn't employ any pausing or resuming. you are just adding a child timeline to a parent timeline and they will naturally play in order.

  • Like 1
Link to comment
Share on other sites

Amazing, Carl to the rescue again!

 

I guess i was wanting to have a mainTL with another timeline resting on pause that would play once the first 2 items in the mainTL have.

 

I have updated my codepen to this...

var mainTL = new TimelineMax()
mainTL
  .to("#moving", 1, {x: 100})
  .play("otherTL")
  
var otherTL = new TimelineMax({paused: true})
  otherTL
  .to("#move", 1, {x: 100})

I have heard about nested timelines in my reading. Does that sound like where i am going with this?

 

Thanks for you help again,

 

Phil

Link to comment
Share on other sites

Glad you found something that worked for you, although that's not a nested timeline. Here's what a nested timeline would look like:

var mainTL = new TimelineMax()
mainTL
  .to("#moving", 1, {x: 100})
  
var otherTL = new TimelineMax();
otherTL
  .to("#move", 1, {x: 100});

mainTL.add(otherTL); //<-- this is nesting

This solution will work great backwards and forwards whereas the way you did it wouldn't really give you a timeline that's completely controllable in any direction (seek, reverse, whatever). 

 

I'd highly recommend watching/reading these: 

http://greensock.com/sequence-video

http://greensock.com/position-parameter

 

Happy tweening!

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