功能概览
让 AI 正确编排多个动画的先后顺序:标题先入、副标题跟入、按钮最后入。
- 多个动画用 setTimeout 拼凑,时序不准且难维护
- 不会用 position 参数精确控制动画起点
- 动画无法暂停、回放、反向播放
- 复杂序列难以嵌套和复用
使用场景
- 做 hero 区多元素依次入场的序列动画
- 做滚动故事线动画
- 做多步骤过渡动画并支持回放
- 把多组动画嵌套成可复用的时间线
适合谁用
- 前端开发者
- 做落地页、品牌站动画的人
- 用 GSAP 做交互动效的产品前端
不适合谁
- 只做单个简单动画的人(用网页动画核心技能包即可)
- 不用 GSAP 的人
普通人版解释
用大白话说这个技能包让 AI 会做「有顺序的动画」。比如你想让标题先出现、副标题跟上、按钮最后入,或者想做一个能回放的滚动故事线,普通 AI 会用 setTimeout 拼凑(容易出错、不好维护),装了这个技能包后 AI 会用专业的时间线 API,动画衔接精准、能暂停、能回放、能复用。
专业版解释
给 Claude Code / Codex 用户GSAP Timeline Skill 教 AI 正确使用 GSAP 的 Timeline(时间线)能力。当你需要把多个动画按顺序串联起来、做复杂的序列动画、控制播放暂停回放时,AI 会用 gsap.timeline()、position 参数、addLabel、嵌套时间线等正确方式实现,而不是用 setTimeout 拼凑。适合做英雄区多元素依次入场、滚动故事线、多步骤过渡等复杂动画场景。
安装方式
复制对应平台的命令到终端执行。安装前建议先确认来源和安全等级。
npx skills add https://github.com/greensock/gsap-skills
SKILL.md 预览
这是这个技能包的核心内容。默认折叠预览,确认后再复制或展开。
# GSAP Timeline
## When to Use This Skill
Apply when building multi-step animations, coordinating several tweens in sequence or parallel, or when the user asks about timelines, sequencing, or keyframe-style animation in GSAP.
**Related skills:** For single tweens and eases use **gsap-core**; for scroll-driven timelines use **gsap-scrolltrigger**; for React use **gsap-react**.
## Creating a Timeline
```javascript
const tl = gsap.timeline();
tl.to(".a", { x: 100, duration: 1 })
.to(".b", { y: 50, duration: 0.5 })
.to(".c", { opacity: 0, duration: 0.3 });
```
By default, tweens are **appended** one after another. Use the **position parameter** to place tweens at specific times or relative to other tweens.
## Position Parameter
Third argument (or position property in vars) controls placement:
- **Absolute**: `1` — start at 1 second.
- **Relative (default)**: `"+=0.5"` — 0.5s after end; `"-=0.2"` — 0.2s before end.
- **Label**: `"labelName"` — at that label; `"labelName+=0.3"` — 0.3s after label.
- **Placement**: `"<"` — start when recently-added animation starts; `">"` — start when recently-added animation ends (default); `"<0.2"` — 0.2s after recently-added animation start.
Examples:
```javascript
tl.to(".a", { x: 100 }, 0); // at 0
tl.to(".b", { y: 50 }, "+=0.5"); // 0.5s after last end
tl.to(".c", { opacity: 0 }, "<"); // same start as previous
tl.to(".d", { scale: 2 }, "<0.2"); // 0.2s after previous start
```
## Timeline Defaults
Pass defaults into the timeline so all child tweens inherit:
```javascript
const tl = gsap.timeline({ defaults: { duration: 0.5, ease: "power2.out" } });
tl.to(".a", { x: 100 }).to(".b", { y: 50 }); // both use 0.5s and power2.out
```
## Timeline Options (constructor)
- **paused: true** — create paused; call `.play()` to start.
- **repeat**, **yoyo** — same as tweens; apply to whole timeline.
- **onComplete**, **onStart**, **onUpdate** — timeline-level callbacks.
- **defaults** — vars merged into every child tween.
## Labels
Add and use labels for readable, maintainable sequencing:
```javascript
tl.addLabel("intro", 0);
tl.to(".a", { x: 100 }, "intro");
tl.addLabel("outro", "+=0.5");
tl.to(".b", { opacity: 0 }, "outro");
tl.play("outro"); // start from "outro"
tl.tweenFromTo("intro", "outro"); // pauses the timeline and returns a new Tween that animates the timeline's playhead from intro to outro with no ease.
```
## Nesting Timelines
Timelines can contain other timelines.
```javascript
const master = gsap.timeline();
const child = gsap.timeline();
child.to(".a", { x: 100 }).to(".b", { y: 50 });
master.add(child, 0);
master.to(".c", { opacity: 0 }, "+=0.2");
```
## Controlling Playback
- **tl.play()** / **tl.pause()**
- **tl.reverse()** / **tl.progress(1)** then **tl.reverse()**
- **tl.restart()** — from start.
- **tl.time(2)** — seek to 2 seconds.
- **tl.progress(0.5)** — seek to 50%.
- **tl.kill()** — kill timeline and (by default) its children.
## Official GSAP Best practices
- ✅ Prefer timelines for sequencing
- ✅ Use the **position parameter** (third argument) to place tweens at specific times or relative to labels.
- ✅ Add **labels** with `addLabel()` for readable, maintainable sequencing.
- ✅ Pass **defaults** into the timeline constructor so child tweens inherit duration, ease, etc.
- ✅ Put ScrollTrigger on the timeline (or top-level tween), not on tweens inside a timeline.
## Do Not
- ❌ Chain animations with **delay** when a **timeline** can sequence them; prefer `gsap.timeline()` and the position parameter for multi-step animation.
- ❌ Forget to pass **defaults** (e.g. `defaults: { duration: 0.5, ease: "power2.out" }`) when many child tweens share the same duration or ease.
- ❌ Forget that **duration** on the timeline constructor is not the same as tween duration; timeline “duration” is determined by its children.
- ❌ Nest animations that contain a ScrollTrigger; ScrollTriggers should only be on top-level Tweens/Timelines.如何使用
安装后,把下面的提示词直接发给 AI 即可触发这个技能包。
- 1.请使用动画序列编排技能包,做一个 hero 区序列动画:标题先入、副标题跟入、按钮最后入。
- 2.请使用动画序列编排技能包,用 position 参数让三个元素依次错开 0.2 秒入场。
- 3.请使用动画序列编排技能包,做一个可以回放的滚动故事线动画。
安全说明
技能包可能不只是提示词。请先查看下面的权限表,了解这个技能包会做什么。
| 权限项 | 状态 | 风险 |
|---|---|---|
| 是否包含脚本 | 否 | 无风险 |
| 是否会执行系统命令 | 否 | 无风险 |
| 是否会读取本地文件 | 否 | 无风险 |
| 是否会联网请求 | 否 | 无风险 |
| 是否适合新手安装 | 否 | 不建议新手 |
相关技能包

网页动画核心技能包
让 AI 正确使用 GSAP 核心 API:做网页动画、SVG 动画、React/Vue 动画时不再写错代码。

滚动动画技能包
让 AI 做对滚动联动的网页动画:视差、滚动进度、钉住章节、滚动触发入场。

React 动画技能包
让 AI 在 React / Next.js 里正确使用 GSAP:useGSAP hook、清理、SSR 不报错。

动画性能优化技能包
让 AI 写出 60fps 流畅的 GSAP 动画:用 transform、will-change、批量处理。

Magic UI 动效组件库
在 shadcn/ui 基础上扩展的动效组件库,50+ 动画展示组件:数字滚动、3D 进度条、光斑背景、刮刮卡交互,现代灵动。

前端设计技能包
让 AI 做有辨识度的前端视觉设计:美学方向、字体、避免模板化的廉价感。