Chapter 08 of 11Part 3 · GSAP

The GSAP timeline: sequencing a hero intro

How timelines place tweens in time with the position parameter, labels and defaults, and how to play, reverse and replay them.

8 minBy Zuzo StudioUpdated

9 min

In this chapter you will

  • place tweens on a timeline with the position parameter and labels
  • set shared durations and eases once with timeline defaults
  • build your whole hero intro as one timeline you can replay and adjust

Before you startThis builds on A GSAP tutorial: tweens, eases and stagger.

Check your understanding

3 questions

Q1On a timeline, you want the buttons to start moving at exactly the same moment as the lede before them. Which position do you pass?

Show the answer

"<" "<" points at the start of the previous tween, so the buttons begin at the same moment as the lede.

Q2Your intro ends with buttons animated by .from(".button", { y: 12 }). Afterwards their CSS hover lift no longer works. Why?

Show the answer

GSAP left an inline transform on each button, which beats the stylesheet GSAP animates through inline styles. Adding clearProps: "transform" removes that inline value when the tween completes, so the hover rule applies again.

Q3A menu opens with a timeline. The reader closes it while it is only half open. What gives the smoothest result?

Show the answer

Call reverse() on the opening timeline reverse() runs the same timeline backwards from wherever it is, so the menu closes from its current state with no jump.

Key takeaways

  1. A timeline places each tween relative to the others, so changing one duration moves everything after it instead of breaking hand made delays.
  2. The position parameter overlaps steps with "-=", adds gaps with "+=", and pairs tweens with "<" and ">".
  3. Labels name points in time, so several tweens can hang off one moment and move together.
  4. Timeline defaults set the duration and ease once, and any tween can still override them.
  5. GSAP writes inline styles, so use clearProps when a stylesheet, such as a hover state, needs control back after the tween.
Up next · Chapter 09 · 11 min Scroll animation with GSAP and CSS Tie motion to scroll with ScrollTrigger and CSS scroll-driven animations, and know when smooth scrolling is worth it.

02FAQ

Questions on this chapter

Something else on your mind? Email the studio and a designer, not a salesperson, replies within a day.

What is the position parameter in GSAP?

It is the optional last argument of timeline methods such as to() and from(), and it sets where the tween goes in time. It can be an absolute time, a label, or a relative value such as "-=0.2" to overlap the previous step or "<" to start with it.

How do I replay or reverse a GSAP timeline?

Keep the timeline in a variable and call restart() to replay it from the start, or reverse() to run it backwards from its current point. Create it with paused: true if it should wait for a click before playing.