Jump to content
Search Community

Nesting timelines

mattVo test
Moderator Tag

Go to solution Solved by PointC,

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

Hi all,

I'm trying to nest a timeline within another but it doesn't seem to work.

 

Here's my demo:

 

The first timeline, red1, alternates between two states, in this example different x positions. I also want this red1 timeline to move like the blue box.

Is this the proper way to go about it? Or is there a better way?

I'm new to this and not very fluent with GSAP, or scripting for that matter.

 

Thanks in advance!
Matt

 

See the Pen QNadVZ by mattVo (@mattVo) on CodePen

Link to comment
Share on other sites

  • Solution

Hi mattVo :)

 

Welcome to the forums.

 

This can work for you with a couple of small changes.

 

1. You have the x position of the red box wiggling back and forth by 3 pixels which is fine, but then you're asking it to move 500 pixels on the x on the other timeline. This causes a fight for control. The simple solution here is to wrap the red box inside a container and then move the container along the x by 500px.

 

2. On your master timeline, you were trying to move the red1 variable by 500px, but red1 is a timeline not the red box itself. 

 

I've forked your pen and made those changes:

See the Pen GZyWJx?editors=1010 by PointC (@PointC) on CodePen

 

Hopefully that gets you closer to what you wanted.

 

Happy tweening and welcome aboard.

:)

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