Communitygithub.com

GSAP

Referência de animação GSAP para HyperFrames. Abrange gsap.to(), from(), fromTo(), easing, stagger, defaults, timelines (gsap.timeline(), parâmetro de posição, rótulos, aninhamento, reprodução) e performance (transformações, will-change, quickTo). Use ao escrever animações GSAP em composições HyperFrames.

O que é GSAP?

Esta skill fornece uma referência completa e abrangente para a biblioteca GSAP (GreenSock Animation Platform), focada no uso dentro do ecossistema HyperFrames. Ela é essencial para desenvolvedores que precisam criar animações web de alta performance, oferecendo desde os métodos básicos como gsap.to(), from() e fromTo() até conceitos avançados como timelines, easing, stagger e matchMedia. A skill cobre as melhores práticas para otimização de performance, como o uso de aliases de transformação (x, y, scale, rotation) e autoAlpha, que evitam repaints e garantem animações suaves na GPU. Além disso, detalha o controle fino de animações com callbacks, valores relativos e função-based values, e explica como gerenciar responsividade e acessibilidade com gsap.matchMedia(). Para fluxos de trabalho mais complexos, a skill ensina a criar timelines aninhadas, usar o parâmetro de posição para sincronização precisa e aplicar rótulos para tornar o código mais legível. Também aborda dicas de performance, como o uso de stagger em vez de múltiplos tweens manuais, a função gsap.quickTo() para atualizações frequentes (ex: mouse tracking) e a importância de pausar/remover animações (kill) para evitar vazamentos de memória. Ela suporta as plataformas Cursor, Codex, Claude Code e vscode-copilot, sendo projetada para consulta rápida durante o desenvolvimento de animações em HyperFrames.

Funciona com~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Geruyang/agent-skills-library/tree/HEAD/original-skills/x-openai-gsap-646176d

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

O que GSAP faz?

Métodos Core de Tween

  • gsap.to(targets, vars) — anima do estado atual para vars. Mais comum.
  • gsap.from(targets, vars) — anima de vars para o estado atual (entradas).
  • gsap.fromTo(targets, fromVars, toVars) — início e fim explícitos.
  • gsap.set(targets, vars) — aplica imediatamente (duração 0).

Sempre use nomes de propriedades em camelCase (ex.: backgroundColor, rotationX).

vars Comuns

  • duration — segundos (padrão 0.5).
  • delay — segundos antes de iniciar.
  • ease — "power1.out" (padrão), "power3.inOut", "back.out(1.7)", "elastic.out(1, 0.3)", "none".
  • stagger — número 0.1 ou objeto: { amount: 0.3, from: "center" }, { each: 0.1, from: "random" }.
  • overwrite — false (padrão), true ou "auto".
  • repeat — número ou -1 para infinito. yoyo — alterna direção com repeat.
  • onComplete, onStart, onUpdate — callbacks.
  • immediateRender — padrão true para from()/fromTo(). Defina false em tweens posteriores que miram a mesma propriedade+elemento para evitar sobrescrição.

Transformações e CSS

Prefira os aliases de transformação do GSAP em vez da string transform raw:

Propriedade GSAPEquivalente
x, y, ztranslateX/Y/Z (px)
xPercent, yPercenttranslateX/Y em %
scale, scaleX, scaleYescala
rotationrotate (graus)
rotationX, rotationYrotate 3D
skewX, skewYskew
transformOrigintransform-origin
  • autoAlpha — prefira em vez de opacity. Em 0: também define visibility: hidden.
  • Variáveis CSS — "--hue": 180.
  • svgOrigin (apenas SVG) — origem no espaço de coordenadas SVG global. Não combine com transformOrigin.
  • Rotação direcional — "360_cw", "-170_short", "90_ccw".
  • clearProps — "all" ou separado por vírgulas; remove estilos inline ao completar.
  • Valores relativos — "+=20", "-=10", "*=2".

Valores Baseados em Função

gsap.to(".item", {
  x: (i, target, targets) => i * 50,
  stagger: 0.1,
});

Easing

Eases embutidos: power1–power4, back, bounce, circ, elastic, expo, sine. Cada um tem .in, .out, .inOut.

Padrões (Defaults)

gsap.defaults({ duration: 0.6, ease: "power2.out" });

Controlando Tweens

const tween = gsap.to(".box", { x: 100 });
tween.pause();
tween.play();
tween.reverse();
tween.kill();
tween.progress(0.5);
tween.time(0.2);

gsap.matchMedia() (Responsivo + Acessibilidade)

Executa a configuração apenas quando uma media query corresponde; reverte automaticamente quando para de corresponder.

let mm = gsap.matchMedia();
mm.add(
  {
    isDesktop: "(min-width: 800px)",
    reduceMotion: "(prefers-reduced-motion: reduce)",
  },
  (context) => {
    const { isDesktop, reduceMotion } = context.conditions;
    gsap.to(".box", {
      rotation: isDesktop ? 360 : 180,
      duration: reduceMotion ? 0 : 2,
    });
  },
);

Timelines

Criando uma Timeline

const tl = gsap.timeline({ defaults: { duration: 0.5, ease: "power2.out" } });
tl.to(".a", { x: 100 }).to(".b", { y: 50 }).to(".c", { opacity: 0 });

Parâmetro de Posição

Terceiro argumento controla o posicionamento:

  • Absoluto: 1 — em 1s
  • Relativo: "+=0.5" — após o fim; "-=0.2" — antes do fim
  • Rótulo: "intro", "intro+=0.3"
  • Alinhamento: "<" — mesmo início do anterior; ">" — após o anterior terminar; "<0.2" — 0.2s após o anterior iniciar
tl.to(".a", { x: 100 }, 0);
tl.to(".b", { y: 50 }, "<"); // mesmo início que .a
tl.to(".c", { opacity: 0 }, "<0.2"); // 0.2s após .b iniciar

Rótulos

tl.addLabel("intro", 0);
tl.to(".a", { x: 100 }, "intro");
tl.addLabel("outro", "+=0.5");
tl.play("outro");
tl.tweenFromTo("intro", "outro");

Opções da Timeline

  • paused: true — cria pausada; chame .play() para iniciar.
  • repeat, yoyo — aplica-se a toda timeline.
  • defaults — vars mescladas em cada tween filho.

Aninhando Timelines

const master = gsap.timeline();
const child = gsap.timeline();
child.to(".a", { x: 100 }).to(".b", { y: 50 });
master.add(child, 0);

Controle de Reprodução

tl.play(), tl.pause(), tl.reverse(), tl.restart(), tl.time(2), tl.progress(0.5), tl.kill().


Performance

Prefira Transform e Opacity

Animar x, y, scale, rotation, opacity permanece no compositor. Evite width, height, top, left quando transformações alcançam o mesmo efeito.

will-change

will-change: transform;

Apenas em elementos que realmente animam.

gsap.quickTo() para Atualizações Frequentes

let xTo = gsap.quickTo("#id", "x", { duration: 0.4, ease: "power3" }),
  yTo = gsap.quickTo("#id", "y", { duration: 0.4, ease: "power3" });
container.addEventListener("mousemove", (e) => {
  xTo(e.pageX);
  yTo(e.pageY);
});

Stagger > Múltiplos Tweens

Use stagger em vez de tweens separados com atrasos manuais.

Limpeza

Pause ou mate animações fora da tela.


Referências (carregadas sob demanda)

  • references/effects.md — Efeitos prontos: texto de máquina de escrever, visualizador de áudio. Leia quando precisar de padrões de efeitos prontos para HyperFrames.

Melhores Práticas

  • Use nomes de propriedades em camelCase; prefira aliases de transformação e autoAlpha.
  • Prefira timelines em vez de encadeamento com delay; use o parâmetro de posição.
  • Adicione rótulos com addLabel() para sequenciamento legível.
  • Passe defaults no construtor da timeline.
  • Armazene o valor de retorno do tween/timeline ao controlar a reprodução.

Não Faça

  • Anime propriedades de layout (width/height/top/left) quando transformações forem suficientes.
  • Use svgOrigin e transformOrigin no mesmo elemento SVG.
  • Encadeie animações com delay quando uma timeline pode sequenciá-las.
  • Crie tweens antes do DOM existir.
  • Pule a limpeza — sempre mate tweens quando não forem mais necessários.

Individual skills in this repo

This repo contains 12 individual skills — each has its own dedicated page.

Geruyang/agent-skills-library

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

Geruyang/agent-skills-library

Set up Tailwind CSS v4 in Expo with react-native-css and NativeWind v5 for universal styling

Geruyang/agent-skills-library

Use for new frontend applications, dashboards, games, creative websites, hero sections, and visually driven UI from scratch, or when the user explicitly asks for a redesign/restyle/modernization. Builds from clean, airy, high-taste, readable image-generated concept design with section-specific references, faithful implementation, and browser testing.

Geruyang/agent-skills-library

Use when testing, debugging, or making targeted improvements to rendered frontend apps through the Build Web Apps or web dev plugin: local dev servers, UI regressions, interaction bugs, console errors, responsive layout, and visual QA. Check whether the Browser plugin is available and use it first when it is; otherwise use regular Playwright with the recorded reason.

Geruyang/agent-skills-library

Design UI surfaces for browser games. Use when the user asks for HUDs, menus, overlays, responsive layouts, or visual direction that must protect the playfield.

Geruyang/agent-skills-library

Guide for building, configuring, and deploying microfrontends on Vercel. Use this skill when the user mentions microfrontends, multi-zones, splitting an app across teams, independent deployments, cross-app routing, incremental migration, composing multiple frontends under one domain, microfrontends.json, @vercel/microfrontends, the microfrontends local proxy, or path-based routing between Vercel projects. Also use when the user asks about shared layouts across projects, navigation between microfrontends, fallback environments, asset prefixes, or feature flag controlled routing.

Geruyang/agent-skills-library

Next.js App Router expert guidance. Use when building, debugging, or architecting Next.js applications — routing, Server Components, Server Actions, Cache Components, layouts, middleware/proxy, data fetching, rendering strategies, and deployment on Vercel.

Geruyang/agent-skills-library

Use when sizing Public Equity Investing positions, finding equity hedges, or building an integrated position-and-hedge risk plan from a listed-equity thesis. Do not use for thesis construction, standalone event underwriting, trade execution, personal investment advice, or credit-instrument risk.

Geruyang/agent-skills-library

Integrate data visualizations into React and Next.js applications. Use when the user needs chart components, UML-like or architecture diagram components, React integration patterns, Next.js client or server boundaries, hydration-safe rendering, lazy loading, framework-aware performance, scroll-driven visual stories, or export guidance.

Geruyang/agent-skills-library

shadcn/ui expert guidance — CLI, component installation, composition patterns, custom registries, theming, Tailwind CSS integration, and high-quality interface design. Use when initializing shadcn, adding components, composing product UI, building custom registries, configuring themes, or troubleshooting component issues.

Geruyang/agent-skills-library

v0 by Vercel expert guidance. Use when discussing AI code generation, generating UI components from prompts, v0 CLI usage, v0 SDK/API integration, or integrating v0 into development workflows with GitHub and Vercel deployment.

Geruyang/agent-skills-library

Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI. Provides project context, component docs, and usage examples. Applies when working with shadcn/ui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for "shadcn init", "create an app with --preset", or "switch to --preset".

Habilidades Relacionadas