Communitygithub.com

MengTo/Skills

Crea un disparador de animación al hacer scroll usando IntersectionObserver con clases y keyframes amigables con Tailwind. Úsalo cuando te pidan scroll-reveal, animación al aparecer, o animaciones secuenciadas de elementos al entrar en el viewport.

¿Qué es Skills?

Esta habilidad de agente de IA proporciona un sistema completo para animar elementos cuando aparecen en el viewport durante el scroll, utilizando la API IntersectionObserver junto con clases Tailwind personalizadas. Es ideal para desarrolladores que trabajan con frameworks UI modernos como Tailwind CSS y necesitan implementar animaciones de entrada con poco código repetitivo. La habilidad genera automáticamente el código JavaScript del observer, las keyframes CSS necesarias y las clases Tailwind que se deben aplicar a los elementos HTML. Soporta personalización de umbral (threshold), margen de raíz (rootMargin), duración, retardo, y estilos de movimiento como fundido, deslizamiento y desenfoque. Funciona en cualquier proyecto web estándar, ya que usa JavaScript vanilla y CSS puro, sin dependencias adicionales. Su flujo de trabajo guía al usuario desde la confirmación del estilo de animación hasta la aplicación final, incluyendo preguntas para clarificar requisitos y trampas comunes a evitar.

Compatible con~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/MengTo/Skills/tree/HEAD/agent-skills/web-design/animation-on-scroll

Preguntar en tu IA favorita

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

Documentación

Habilidad de Animación al Hacer Scroll

Flujo de trabajo

  1. Confirmar el estilo de animación, la temporización, y si las animaciones deben ejecutarse una vez o repetirse.
  2. Proporcionar las keyframes + el fragmento JS del observer y la clase exacta de Tailwind a aplicar.
  3. Ofrecer solo ajustes enfocados (threshold, rootMargin, duración, retardo, valores de transformación/desenfoque).

Lista de verificación de uso

  • Insertar el fragmento JS en el <head> después de las keyframes.
  • Agregar la clase de animación y animate-on-scroll a los elementos.
  • Asegurarse de que el nombre de las keyframes coincida con la referencia de animación de Tailwind.

Disparador IntersectionObserver

<script>
  /*
    Animación secuenciada al hacer scroll cuando es visible. Requiere Keyframes de Animación. Uso:

    1) Insertar este código en el <head> junto con el código de Keyframes de Animación.

    2) Agregar a las Clases de Tailwind: [animation:animationIn_0.8s_ease-out_0.1s_both] animate-on-scroll
  */
  (function () {
    // Inyectar CSS para estados pausados/en ejecución
    const style = document.createElement("style");
    style.textContent = `
      /* Por defecto: pausado */
      .animate-on-scroll { animation-play-state: paused !important; }
      /* Activado por JS */
      .animate-on-scroll.animate { animation-play-state: running !important; }
    `;
    document.head.appendChild(style);

    const once = true;

    if (!window.__inViewIO) {
      window.__inViewIO = new IntersectionObserver((entries) => {
        entries.forEach((entry) => {
          if (entry.isIntersecting) {
            entry.target.classList.add("animate");
            if (once) window.__inViewIO.unobserve(entry.target);
          }
        });
      }, { threshold: 0.2, rootMargin: "0px 0px -10% 0px" });
    }

    window.initInViewAnimations = function (selector = ".animate-on-scroll") {
      document.querySelectorAll(selector).forEach((el) => {
        window.__inViewIO.observe(el); // observar dos veces es no-op
      });
    };

    document.addEventListener("DOMContentLoaded", () => initInViewAnimations());
  })();
</script>

Keyframes

<style>
  /*
    Introducción de animación secuenciada. Uso:

    1) Insertar este código en el <head>

    2) Agregar a las Clases de Tailwind: [animation:animationIn_0.8s_ease-out_0.1s_both]
  */
  @keyframes animationIn {
    0% {
      opacity: 0;
      transform: translateY(30px);
      filter: blur(8px);
    }

    100% {
      opacity: 1;
      transform: translateY(0);
      filter: blur(0px);
    }
  }
</style>

Ejemplo con Tailwind

<div class="animate-on-scroll [animation:animationIn_0.8s_ease-out_0.1s_both]">
  ...
</div>

Parámetros de personalización

  • Disparador: ajustar threshold y rootMargin para revelaciones más tempranas o tardías.
  • Repetición: establecer once = false para permitir repeticiones al volver a entrar.
  • Movimiento: modificar translateY y blur en las keyframes.
  • Temporización: cambiar duración y retardo en el valor de animación de Tailwind.

Errores comunes

  • Olvidar incluir las keyframes antes del fragmento JS.
  • Usar un nombre de keyframe diferente al de la animación de Tailwind.
  • Las animaciones no se ejecutan porque el elemento ya está en el viewport antes de inicializar el observer.

Preguntas para hacer cuando faltan especificaciones

  • ¿Las animaciones deben ejecutarse una vez o cada vez que el elemento vuelva a entrar?
  • ¿Qué tan antes de entrar al viewport deben comenzar?
  • ¿Qué estilo de movimiento (fade, slide, blur, scale) desea?

Individual skills in this repo

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

MengTo/Skills

Create polished 60 fps 4:3 4K browser screen-recording style videos from Codex in-app browser captures, with browser-only crop, natural macOS cursor styling, deliberate click choreography, zoom-follow framing, ffprobe/thumbnail verification, and optional native recording compatibility checks. Use when the user asks to record or re-record browser actions, show cursor clicks and zooms, make Dribbble/UI inspiration or product demo recordings, or asks whether Codex, Playwright, or an MCP can produce a natural browser demo video.

MengTo/Skills

Generate ElevenLabs text-to-speech audio from scripts or inline text using local voice profiles. Use when the user asks for ElevenLabs, text-to-speech, TTS, narration, voiceover, speech audio, or voice generation; load voice names, voice ids, emails, owners, and account-specific defaults only from local config outside the skill.

MengTo/Skills

Profile, audit, and optimize frontend page performance with emphasis on animation work, memory-leak risks, long-session slowdowns, CSS animations, canvas/WebGL requestAnimationFrame loops, marquees, skeletons, GSAP/Three/Matter effects, timers, listeners, and observers. Use when the user asks to make animations performant, pause offscreen animations, look for memory leaks, profile pages that slow the computer over time, fix janky scrolling, reduce CPU/GPU use, or repeat the "only play in view" optimization on React/Vite/Next/frontend pages using Codex Browser.

MengTo/Skills

Turn a reference video into a super detailed recreation or inspiration prompt. Use when the user provides, mentions, uploads, links, or points to a video and asks to analyze the design, UI, animations, transitions, scroll interactions, typography, colors, assets, WebGL/Three.js, storytelling, section-by-section behavior, or to create a prompt/article that recreates the page, app, interaction, or motion system.

MengTo/Skills

Use when designing or implementing product-grade web motion like Stripe, Linear, Apple, and Vercel. Covers motion principles, easing/duration defaults, choreography patterns, scroll/hover interactions, performance, accessibility (reduced motion), and implementation guidance.

MengTo/Skills

Create premium cinematic web motion systems with GSAP, ScrollTrigger, and Lenis. Use for luxury editorial websites, creative studio portfolios, Awwwards-style interactions, smooth scroll reveals, staggered text, parallax, pinned sections, magnetic hover states, custom cursors, and mouse-reactive layered movement.

MengTo/Skills

Create cinematic scroll-driven landing pages with Lenis smooth scrolling, GSAP ScrollTrigger, scroll-linked progression, staggered text reveals, sticky card stacks, parallax backgrounds, scroll-scrubbed transitions, footer reveals, and immersive preloaders. Use when analyzing or building premium editorial scroll experiences, sticky project stacks, kinetic typography, or section-by-section storytelling.

MengTo/Skills

Use when designing or rewriting a high-converting SaaS pricing page (structure, plan design, copywriting, SEO/AEO, FAQs, layout patterns, experiments). Includes checklists, templates, and common pitfalls.

MengTo/Skills

Use when creating or refining WebGL-heavy landing pages and you need to steer toward a specific visual outcome (premium, technical, playful, cinematic) while balancing conversion clarity, performance, and implementation complexity.

Skills relacionados