時間軸

巢狀 Timeline + 控制台

master 嵌 child timeline、labels 跳段、timeScale 與 seek。

導讀

大段動畫拆成 intro / main / outro 子時間軸,master 只負責組裝與全域控制。

看什麼
各段落標籤;timeScale 加速時整段一起變快。
怎麼試
按 label 跳段、調 timeScale、用 progress scrub 整條 master。
Skill 對應:nested timelines, addLabel, timeScale, tweenFromTo
  • master.add(child, position) 巢狀時間軸
  • addLabel 後可用 play("outro") 跳段
  • timeScale 加速/減速整條 master
  • ScrollTrigger 只能掛在最外層 timeline,不要掛在 child 上
const intro = gsap.timeline();
intro.to(".a", { autoAlpha: 1 }).to(".b", { y: 0 });

const master = gsap.timeline();
master.addLabel("intro")
  .add(intro)
  .addLabel("main")
  .to(".c", { scale: 1.2 });
master + children
A
B
C
D

label —