Communitygithub.com

Animação ao Rolar (MengTo/Skills)

Cria um gatilho de animação ao rolar a página usando IntersectionObserver, com classes e keyframes amigáveis ao Tailwind. Utilize quando for solicitado scroll-reveal, animate-on-scroll ou sequenciamento de animações de elementos ao entrarem no viewport.

O que é Skills)?

Esta skill configura animações acionadas pelo scroll em projetos que usam Tailwind CSS. Ela injeta um pequeno snippet de JavaScript que utiliza a IntersectionObserver API para adicionar uma classe (`.animate`) nos elementos com a classe `.animate-on-scroll` assim que eles ficam visíveis na tela, com um threshold de 0.2 e margem de -10% na parte inferior. As animações ficam pausadas por padrão (via CSS `animation-play-state: paused`) e são ativadas pela classe `.animate`. Além disso, a skill fornece keyframes CSS prontos (com fade, slide de 30px para cima e blur de 8px) que podem ser personalizados. É ideal para efeitos como fade-in, slide-in e blur-in, suportando execução única ou repetida. Funciona em qualquer framework que use Tailwind, como Next.js, React, Vue, ou HTML puro, e requer apenas a inserção do código no `<head>` e a aplicação das classes nos elementos desejados.

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

Perguntar na sua IA favorita

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

Documentação

Skill de Animação ao Rolar

Fluxo de trabalho

  1. Confirmar o estilo da animação, o timing e se as animações devem ser executadas uma vez ou repetidas.
  2. Fornecer os keyframes + o snippet JS do observer e a classe exata do Tailwind a ser aplicada.
  3. Oferecer ajustes focados apenas (threshold, rootMargin, duração, delay, valores de transform/blur).

Lista de verificação

  • Insira o snippet JS no <head> após os keyframes.
  • Adicione a classe de animação e animate-on-scroll aos elementos.
  • Certifique-se de que o nome dos keyframes corresponda à referência de animação do Tailwind.

Gatilho IntersectionObserver

<script>
  /*
    Animação sequencial ao rolar quando visível. Requer Animation Keyframe. Uso:

    1) Insira este código no <head> junto com o código do Animation Keyframe.

    2) Adicione às classes Tailwind: [animation:animationIn_0.8s_ease-out_0.1s_both] animate-on-scroll
  */
  (function () {
    // Injeta CSS para estados pausado/em execução
    const style = document.createElement("style");
    style.textContent = `
      /* Padrão: pausado */
      .animate-on-scroll { animation-play-state: paused !important; }
      /* Ativado pelo 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 duas vezes é um 
      });
    };

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

Keyframes

<style>
  /*
    Introdução de animação sequencial. Uso:

    1) Insira este código no <head>

    2) Adicione às classes 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>

Exemplo com Tailwind

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

Opções de personalização

  • Gatilho: ajuste threshold e rootMargin para revelações mais cedo/mais tarde.
  • Repetição: defina once = false para permitir repetições ao reentrar.
  • Movimento: ajuste translateY e blur nos keyframes.
  • Timing: altere duração e delay no valor de animação do Tailwind.

Armadilhas comuns

  • Esquecer de incluir os keyframes antes do snippet JS.
  • Usar um nome de keyframe diferente do referenciado na animação do Tailwind.
  • Animações não executando porque o elemento já está visível antes da inicialização do observer.

Perguntas a fazer quando as especificações estiverem incompletas

  • As animações devem ser executadas uma vez ou toda vez que o elemento reentrar?
  • A que distância antes de entrar no viewport elas devem começar?
  • Qual estilo de movimento (fade, slide, blur, escala) você deseja?

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.

Habilidades Relacionadas