Jump to content
Search Community

Compound tweens?

lunadigital test
Moderator Tag

Go to solution Solved by Carl,

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've scoured the internet and docs for an answer to this, but I'm still coming up short. I'm hoping to combine GSAP tweens with different durations along a timeline—for example, animate a motion sequence, then animate a slow camera zoom on top of it.

 

I can pull it off simply by writing out .to or .from methods, but the minute I combine everything into a timeline it assumes I want them all to play sequentially (which I do, kind of).

 

If I were to do this in an animation program, I would animate the sequence then create a parent element to animate the scale. I know GSAP is a completely different beast, though, so any advice will help. Right now, I'm just playing the timeline, then animating a scale outside of the timeline variable so they play on top of each other. I'm hoping there's a more elegant solution though.

See the Pen LEagwZ by anon (@anon) on CodePen

Link to comment
Share on other sites

  • Solution

Hi and welcome to the GreenSock forums.

 

Thanks for the demo, it really helped me understand what you were trying to achieve.

 

Does this help:

 

var tl = new TimelineLite();
tl.to('#box', .5, {left:-100})
  .to('#box', 1, {left:100, repeat:5, yoyo:true, ease:Power1.easeInOut})


// add a tween that is as long as the total duration of all previous animations and place it at the beginning of the timeline
  .to('#box', tl.duration(), {scale: 1.5}, 0)

Demo http://codepen.io/GreenSock/pen/yywQpL?editors=001

 

Please be sure to read this article on using the position parameter to schedule tweens in a timeline: http://greensock.com/position-parameter

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