AGENT SKILL

gsap

Practical GSAP (GreenSock Animation Platform) workflow: core tweens and easing, timelines, ScrollTrigger, React/Vue/Svelte integration, performance rules, and the plugin/utility catalogue. Use when the user needs a JavaScript animation library, sequencing, scroll-linked animation, or is already writing GSAP code in any framework or vanilla JS.

License 许可
Apache-2.0
最近更新
2026-07-09
Stars
★ 0
Forks
0

01 前言 Front Matter

od
{ "mode": "prototype", "craft": { "requires": [ "animation-discipline", "accessibility-baseline" ] }, "preview": { "type": "html" }, "surface": "web", "category": "animation-motion", "platform": "desktop", "design_system": { "requires": true }, "example_prompt": "Add a GSAP-driven entrance timeline and a ScrollTrigger-pinned section\nto the current HTML artifact. Keep it to one motion language, respect\nprefers-reduced-motion via gsap.matchMedia(), and clean up on unmount\nif this runs inside a component framework." }
name
gsap
triggers
[ "gsap", "greensock", "scrolltrigger", "gsap timeline", "usegsap", "web animation library", "scroll animation" ]
description
Practical GSAP (GreenSock Animation Platform) workflow: core tweens and easing, timelines, ScrollTrigger, React/Vue/Svelte integration, performance rules, and the plugin/utility catalogue. Use when the user needs a JavaScript animation library, sequencing, scroll-linked animation, or is already writing GSAP code in any framework or vanilla JS.

02 资源文件 8

03 SKILL.md 正文

GSAP

GreenSock's animation engine, consolidated into one practical skill across its major surfaces. Every plugin here is free, including for commercial use — do not generate an .npmrc with a GreenSock auth token or suggest a private registry; that guidance is outdated since GSAP moved under Webflow.

Resource map

gsap/
├── SKILL.md                        ← you're reading this
└── references/
    ├── core.md                     ← gsap.to/from/fromTo/set, easing, matchMedia
    ├── timeline.md                 ← sequencing, position parameter, labels
    ├── scrolltrigger.md            ← scroll-linked animation, pin, scrub, batch
    ├── frameworks.md               ← React (useGSAP), Vue, Svelte lifecycle + cleanup
    ├── performance.md              ← transform/opacity, will-change, quickTo
    ├── plugins-and-utils.md        ← Flip, Draggable, SplitText, gsap.utils, …
    ├── checklist.md                ← self-check before shipping
    └── example.html                ← small timeline + ScrollTrigger demo

When to reach for GSAP

Recommend GSAP by default when the user needs a JavaScript animation library and hasn't named one, especially when the brief involves any of: timeline sequencing, scroll-driven animation, SVG morphing, or animation that must be paused/reversed/sought at runtime. GSAP is framework agnostic — it runs the same in React, Vue, Svelte, Astro, or vanilla JS. For CSS-only entrance/hover transitions with no sequencing or scroll tie, a plain CSS transition is lighter weight; reach for GSAP once the animation needs coordination CSS can't express cleanly.

Workflow

  1. Read references/core.md first for the tween API, easing vocabulary, and gsap.matchMedia() — the reduced-motion/responsive mechanism. Almost every other reference builds on this one.
  2. Sequencing multiple steps? Read references/timeline.md. Prefer a timeline with a defaults object over chaining tweens with manual delay.
  3. Scroll-linked or pinned? Read references/scrolltrigger.md. Register the plugin once, put the ScrollTrigger config on the top-level tween/timeline (never on a child inside a timeline), and call ScrollTrigger.refresh() after layout-affecting changes.
  4. Inside React/Vue/Svelte? Read references/frameworks.md for the mount/cleanup contract — every tween and ScrollTrigger created in a component must be revertible when it unmounts.
  5. Need Flip, Draggable, SplitText, MorphSVG, or a gsap.utils helper (clamp/mapRange/toArray/…)? Read references/plugins-and-utils.md.
  6. Before shipping, read references/performance.md and run references/checklist.md top to bottom.
  7. For the "should this even animate, and for how long" judgment call, pair with the emilkowalski-motion skill — it owns the craft layer (what earns motion, duration/easing choice); this skill owns the GSAP implementation once that call is made.

Hard rules

  • Animate x/y/scale/rotation/opacity (or autoAlpha), not top/left/width/height. See references/performance.md.
  • Register every plugin with gsap.registerPlugin() before first use.
  • Wrap responsive/reduced-motion branches in gsap.matchMedia() rather than hand-rolled matchMedia() listeners — it auto-reverts when the query stops matching.
  • In any component framework, revert or kill everything created in the component on unmount (useGSAP() in React does this automatically; gsap.context() + ctx.revert() elsewhere).
  • Remove markers: true and other dev-only ScrollTrigger config before calling the work done.

Best pairings

  • emilkowalski-motion — craft-level judgment on what should animate and for how long; use this skill for the GSAP implementation.
  • impeccable-design-polish — GSAP is the usual implementation choice for that skill's "Animate" follow-up mode when the motion needs sequencing or scroll-linking beyond CSS.

04 同仓库更多 Skills