Communitygithub.com

GSAP - Animaciones para HyperFrames

Referencia de animaciones GSAP para HyperFrames. Cubre gsap.to(), from(), fromTo(), easing, stagger, defaults, timelines (gsap.timeline(), parámetro de posición, etiquetas, anidamiento, reproducción) y rendimiento (transformaciones, will-change, quickTo). Úsalo al escribir animaciones GSAP en composiciones de HyperFrames.

¿Qué es GSAP - Animaciones para HyperFrames?

Esta skill proporciona una referencia completa y práctica de GreenSock Animation Platform (GSAP) para desarrolladores que trabajan con HyperFrames. Cubre los métodos Tween core (gsap.to(), from(), fromTo(), set()), propiedades comunes en camelCase (duración, delay, ease, stagger, repeat, yoyo, callbacks), transformaciones y propiedades CSS optimizadas (autoAlpha, variables CSS, rotación direccional, valores relativos), y valores basados en funciones para animaciones dinámicas. Además, detalla la creación y control de timelines con el parámetro de posición, etiquetas, anidamiento y opciones de reproducción, así como consejos de rendimiento (preferir transform/opacity, will-change, gsap.quickTo() para actualizaciones frecuentes). Incluye referencias a patrones de efectos listos para usar y mejores prácticas para evitar errores comunes como animar propiedades de layout innecesariamente o no limpiar animaciones. Compatible con GSAP y entornos que ejecuten código JavaScript.

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

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

GSAP

Métodos Tween Principales

  • gsap.to(targets, vars) — anima desde el estado actual a vars. El más común.
  • gsap.from(targets, vars) — anima desde vars al estado actual (entradas).
  • gsap.fromTo(targets, fromVars, toVars) — inicio y final explícitos.
  • gsap.set(targets, vars) — aplica inmediatamente (duración 0).

Usa siempre nombres de propiedad en camelCase (ej. backgroundColor, rotationX).

Propiedades vars comunes

  • duration — segundos (por defecto 0.5).
  • delay — segundos antes del inicio.
  • ease — "power1.out" (por defecto), "power3.inOut", "back.out(1.7)", "elastic.out(1, 0.3)", "none".
  • stagger — número 0.1 u objeto: { amount: 0.3, from: "center" }, { each: 0.1, from: "random" }.
  • overwrite — false (por defecto), true o "auto".
  • repeat — número o -1 para infinito. yoyo — alterna dirección con repetición.
  • onComplete, onStart, onUpdate — callbacks.
  • immediateRender — por defecto true para from()/fromTo(). Ponlo en false en tweens posteriores que apunten a la misma propiedad+elemento para evitar sobrescritura.

Transformaciones y CSS

Prefiere los alias de transformación de GSAP en lugar de la cadena transform cruda:

Propiedad GSAPEquivalente
x, y, ztranslateX/Y/Z (px)
xPercent, yPercenttranslateX/Y en %
scale, scaleX, scaleYscale
rotationrotate (deg)
rotationX, rotationYrotate 3D
skewX, skewYskew
transformOrigintransform-origin
  • autoAlpha — preferible sobre opacity. En 0: también establece visibility: hidden.
  • Variables CSS — "--hue": 180.
  • svgOrigin (solo SVG) — origen en el espacio de coordenadas SVG global. No se combina con transformOrigin.
  • Rotación direccional — "360_cw", "-170_short", "90_ccw".
  • clearProps — "all" o separado por comas; elimina estilos inline al completar.
  • Valores relativos — "+=20", "-=10", "*=2".

Valores basados en funciones

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

Easing

Eases integrados: power1–power4, back, bounce, circ, elastic, expo, sine. Cada uno tiene .in, .out, .inOut.

Valores por defecto

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

Control de 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() (Responsive + Accesibilidad)

Ejecuta la configuración solo cuando coincide una media query; se revierte automáticamente cuando deja de coincidir.

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

Crear una 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 Posición

El tercer argumento controla la colocación:

  • Absoluto: 1 — en 1s
  • Relativo: "+=0.5" — después del final; "-=0.2" — antes del final
  • Etiqueta: "intro", "intro+=0.3"
  • Alineación: "<" — mismo inicio que el anterior; ">" — después de que el anterior termine; "<0.2" — 0.2s después de que el anterior comience
tl.to(".a", { x: 100 }, 0);
tl.to(".b", { y: 50 }, "<"); // mismo inicio que .a
tl.to(".c", { opacity: 0 }, "<0.2"); // 0.2s después de que .b comience

Etiquetas

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

Opciones de Timeline

  • paused: true — crea pausada; llama a .play() para iniciar.
  • repeat, yoyo — se aplican a toda la timeline.
  • defaults — vars fusionadas en cada tween hijo.

Anidamiento de Timelines

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

Control de Reproducción

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


Rendimiento

Prefiere Transform y Opacity

Animar x, y, scale, rotation, opacity se mantiene en el compositor. Evita width, height, top, left cuando las transformaciones logren el mismo efecto.

will-change

will-change: transform;

Solo en elementos que realmente se animen.

gsap.quickTo() para Actualizaciones Frecuentes

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 en Lugar de Muchos Tweens

Usa stagger en lugar de tweens separados con delays manuales.

Limpieza

Pausa o mata animaciones fuera de pantalla.


Referencias (cargadas bajo demanda)

  • references/effects.md — Efectos listos para usar: texto de máquina de escribir, visualizador de audio. Léelo cuando necesites patrones de efectos predefinidos para HyperFrames.

Mejores Prácticas

  • Usa nombres de propiedad en camelCase; prefiere alias de transformación y autoAlpha.
  • Prefiere timelines sobre encadenamiento con delay; usa el parámetro de posición.
  • Añade etiquetas con addLabel() para una secuenciación legible.
  • Pasa defaults al constructor de la timeline.
  • Almacena el valor de retorno del tween/timeline al controlar la reproducción.

No Hacer

  • Animar propiedades de layout (width/height/top/left) cuando las transformaciones sean suficientes.
  • Usar svgOrigin y transformOrigin en el mismo elemento SVG.
  • Encadenar animaciones con delay cuando una timeline pueda secuenciarlas.
  • Crear tweens antes de que exista el DOM.
  • Omitir la limpieza — siempre mata los tweens cuando ya no sean necesarios.

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".

Skills relacionados