Jump to content
Search Community

Nested timelines and progress?

Wargasmic test
Moderator Tag

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

is there any way to set the progress of a nested timeline but have it set the progress of the parent timeline relatively?

 

Say I have a parent timeline with 2 child timelines of 5 second durations, first starting at 0 seconds and the second starting at 5 seconds giving a total duration of 10 seconds. I want to set the progress of the second child to 0.5 which would set the parent timeline to 0.75.

 

Is this possible?

 

 

Link to comment
Share on other sites

A child shouldn't control its parent, but you can definitely get the effect you're after with a little math. I've wrapped it into a function for you: 

function setChildProgress(animation, progress) {
    var parent = animation.timeline,
        time = animation.startTime() + (animation.duration() * progress); //figure out the position (time) on the parent's timeline
    parent.progress(time / parent.duration());
}

I haven't tested it, but that should work. 

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