gsap-web
This skill should be used when the user asks to "build a scroll animation", "add ScrollTrigger", "pin a section while scrolling", "scrub an animation to scroll", "create a hero timeline", "do a horizontal scroll section", "split text and animate words", "animate a layout change with GSAP Flip", "sync ScrollTrigger with Lenis", "Lenis smooth scroll jittery", "ScrollTrigger markers drift", "ScrollTrigger pins break with Lenis/Locomotive", or "set up smooth scroll with GSAP pinning". Covers GSAP timelines, ScrollTrigger, SplitText, Flip, and Lenis/Locomotive smooth-scroll sync for code-driven web motion.
1How It Works & Mechanism
Organize around a single master timeline: use a single playhead with relative position parameters and labels to choreograph multi-stage animations into an individually seekable unit.
Prefer one timeline over many independent tweens — it gives a single playhead, relative positioning, and easy reversal.
Drive scroll via the four core elements of ScrollTrigger (start/end/pin/scrub), emphasizing that scrubbed tweens must use ease: none for a linear 1:1 mapping with scroll progress.
start: "top top", // when trigger top hits viewport top
Lenis smooth scroll jitter, marker drift, and broken pins share a single root cause (two independent animation loops ticking separately); the solution is a unified loop where gsap.ticker drives Lenis and each Lenis scroll event updates ScrollTrigger.
lenis.on("scroll", ScrollTrigger.update); // 1. update ScrollTrigger on every Lenis scroll
Use dedicated primitives for text reveals and layout transitions: SplitText (wait for font loading, apply overflow:hidden for line masks, invoke revert to restore DOM) and Flip (record state first, mutate DOM immediately, then animate the delta).
Always split AFTER web fonts load (`document.fonts.ready.then(...)`) to prevent wrong line breaks.
Execute mandatory one-off teardown in SPAs and frameworks: use gsap.context() or ctx.revert() from useGSAP to clean up tweens, ScrollTrigger instances, and inline styles to prevent trigger leaks and ghost pin accumulation.
return () => ctx.revert(); // kills tweens, triggers, and reverts inline styles
2Core Capabilities
3External Dependencies
| Kind | Dependency / Endpoint |
|---|---|
| package | gsap 及插件 ScrollTrigger / SplitText / Flip(正文口径:3.12+ 全部免费含商用) |
| network | 交付模板从 cdnjs 取 GSAP(产物期引用,浏览器打开时拉取;执行期本 skill 不请求) |
| package | lenis(平滑滚动,与 ScrollTrigger 单循环同步;Locomotive 走 scrollerProxy 变体) |
| package | @gsap/react(useGSAP)与 React 清理路径 |
| cli | npx / Playwright(宿主侧截图工具)与仓库根 scripts/ 助手(seek-shot.sh、contact-sheet.sh 依赖 ffmpeg) |
4Recommended Governance & Evidence
- 网络端点: Declared external network access: Zero outbound requests during execution; the deliverable template examples/standalone-template.html loads gsap 3.13.0 from cdnjs (runtime asset dependency, not execution-time egress)
- 本地工作目录: File I/O and artifact outputs: Zero disk writes within the skill directory; outputs 1 self-contained .html deliverable or user-project module written directly by the agent
5Second-Pass Verification
- [unlocatable] GSAP 3.12+ 全部插件免费含商用这一许可声明是否可在源码内核实 — SKILL.md 首段声明 As of GSAP 3.12+, every plugin (ScrollTrigger, SplitText, Flip, MotionPath, MorphSVG, Draggable, Observer) is 100% free, including for commercial use. 但仓库内只有自身 MIT LICENSE,没有上游许可文件或链接,属外部事实声明,源码内不可复核,按文档声明记录。
- [ok] Lenis 同步的乘 1000 单位换算与不要再开 rAF 是否前后一致 — SKILL.md 三段互相印证:接线代码 gsap.ticker.add((t) => lenis.raf(t * 1000))、Critical 段明写 ticker 传秒而 raf 要毫秒、Common bugs 段把 leftover requestAnimationFrame(raf) loop 列为抖动根因;references 的调试清单第 1、2 条同样指向这两点。
- [ok] examples 里的两个文件是否真的可直接用 — hero-timeline.js 头注释给出所需 markup 与 CSS 前提(.line 需 overflow:hidden),并内置 document.readyState 自动启动;standalone-template.html 除 cdnjs GSAP 外无外部依赖,自带 ?t=N 冻结与 window.__ready,与 SKILL.md 的输出契约逐条对应。
- [discrepancy] Packaged helper 的路径基准 — SKILL.md 写 scripts/seek-shot.sh anim.html 0 1.5 3,但 scripts/ 在仓库根而非本 skill 目录(目录内只有 examples/ 与 references/),单装形态下该相对路径不成立;好在 examples/standalone-template.html 自带 harness,可自给自足。
6Verdict & Scenarios
1c57c75354a29de0…