# Gsap Animation Assistant

> GSAP assistant for generating and reviewing frontend animation code with timelines, ScrollTrigger, plugins, framework integration, cleanup, and performance guidance.

- Skill: `infometa/gsap-animation-assistant` (Agent Skill, multi-file: 9 files)
- Install (CLI): `npx skillmds@latest add infometa/gsap-animation-assistant`
- Raw SKILL.md: https://api.skillmd.com/api/skills/infometa/gsap-animation-assistant/raw
- Safety review: pending (external: skill-scanner PASS, skillspector CAUTION)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Web & Frontend
- License: MIT
- Author: infometa (https://skillmd.com/u/infometa)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/infometa/gsap-animation-assistant

---


# GSAP 动画开发助手

## When to Use This Skill

Use this skill when the user asks for frontend animation work involving JavaScript, GSAP, React, Vue, Svelte, vanilla JS, scroll-driven animation, timeline sequencing, SVG animation, plugin usage, or animation performance review.

Typical triggers:

- "帮我做一个页面动效"
- "用 GSAP 实现动画"
- "实现滚动触发动画 / parallax / pin / scrub"
- "给 React/Vue/Svelte 组件加动画"
- "用 timeline 编排多步骤动画"
- "检查这段动画代码有没有内存泄漏或性能问题"
- "从 CSS animation 改成可控的 JS 动画"
- "SplitText / MorphSVG / Flip / Draggable / ScrollSmoother 怎么用"

If the user asks for a JavaScript animation library but does not specify one, recommend GSAP when they need timelines, scroll-driven animation, SVG animation, or framework-agnostic control. If the user already chose another library, respect that choice.

## Before Answering

1. Identify the user's framework: vanilla JS, React, Next.js, Vue, Nuxt, Svelte, or unknown.
2. Identify the animation type: simple tween, sequence/timeline, scroll-driven effect, plugin use, framework integration, or performance/debugging.
3. Read the relevant reference file before giving detailed API guidance.
4. Prefer small, production-safe examples with cleanup logic.
5. Keep GSAP API names and code in English; explain behavior in the user's language.

## Reference Routing

| User Need | Read This Reference |
|----------|---------------------|
| Basic tween, easing, stagger, transform, responsive/reduced motion | `references/gsap-core.md` |
| Multi-step sequencing, labels, position parameter, playback control | `references/gsap-timeline.md` |
| Scroll animation, pinning, scrub, parallax, ScrollTrigger cleanup | `references/gsap-scrolltrigger.md` |
| Flip, Draggable, SplitText, MorphSVG, DrawSVG, MotionPath, CustomEase, plugin registration | `references/gsap-plugins.md` |
| `gsap.utils`, clamp, mapRange, random, snap, toArray, wrap, pipe | `references/gsap-utils.md` |
| React, Next.js, `useGSAP`, refs, `gsap.context()`, SSR cleanup | `references/gsap-react.md` |
| Jank, 60fps, transform vs layout, batching, ScrollTrigger performance | `references/gsap-performance.md` |
| Vue, Nuxt, Svelte, SvelteKit, lifecycle and unmount cleanup | `references/gsap-frameworks.md` |

## Core Guidance

- Prefer transform aliases like `x`, `y`, `scale`, `rotation`, and `autoAlpha` over layout-heavy properties where possible.
- Use `gsap.timeline()` for sequenced animations instead of chaining many delays.
- Register plugins once with `gsap.registerPlugin(...)`.
- For scroll-driven animation, use `ScrollTrigger` and call `ScrollTrigger.refresh()` after meaningful layout changes.
- For React, prefer `@gsap/react` `useGSAP()` with a scope, or `gsap.context()` with cleanup.
- For Vue/Svelte, create animations after mount and kill/revert them on unmount.
- Respect `prefers-reduced-motion`; use `gsap.matchMedia()` when responsive/reduced-motion behavior matters.
- Do not leave invisible elements blocking clicks; prefer `autoAlpha` for fade in/out.

## Common Patterns

### Basic Tween

```javascript
import { gsap } from "gsap";

gsap.to(".box", {
  x: 100,
  autoAlpha: 1,
  duration: 0.6,
  ease: "power2.inOut"
});
```

### Timeline

```javascript
const tl = gsap.timeline({ defaults: { duration: 0.5, ease: "power2.out" } });

tl.to(".title", { y: 0, autoAlpha: 1 })
  .to(".card", { y: 0, autoAlpha: 1, stagger: 0.08 }, "-=0.2");
```

### ScrollTrigger

```javascript
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";

gsap.registerPlugin(ScrollTrigger);

gsap.to(".panel", {
  xPercent: -100,
  scrollTrigger: {
    trigger: ".section",
    start: "top top",
    end: "bottom top",
    scrub: true,
    pin: true
  }
});
```

### React Cleanup

```javascript
import { useRef } from "react";
import { gsap } from "gsap";
import { useGSAP } from "@gsap/react";

gsap.registerPlugin(useGSAP);

export function Hero() {
  const container = useRef(null);

  useGSAP(() => {
    gsap.from(".headline", { y: 24, autoAlpha: 0, duration: 0.6 });
  }, { scope: container });

  return <section ref={container}><h1 className="headline">Hello</h1></section>;
}
```

## Output Requirements

When generating code:

- State required imports and plugin registration.
- Include cleanup logic for framework components.
- Avoid global selectors in component code unless scoped.
- Prefer concise code that can be pasted into a user's project.
- Mention required package install only when needed: `npm install gsap @gsap/react` for React usage.
- Do not claim to run or preview animations unless actually executed in the user's project.

When reviewing code:

- Check cleanup on unmount.
- Check duplicate plugin registration or missing plugin registration.
- Check layout-thrashing properties when transform alternatives exist.
- Check ScrollTrigger refresh/kill/revert behavior.
- Check accessibility and reduced-motion handling when animation is prominent.

## Safety and Boundaries

- GSAP is a frontend animation library. Do not perform account login, payment, scraping, destructive filesystem operations, or external publishing as part of animation guidance.
- GSAP and its plugins are free via the public `gsap` npm package. Do not ask users for Club GSAP credentials, private registry tokens, or `.npmrc` auth configuration.
- Brand assets from the source repository should only be used according to GreenSock's branding expectations.

## Source References

This merged skill is derived from GreenSock's official `greensock/gsap-skills` repository under the MIT license. The original eight skills are preserved under `references/` for detailed lookup.

