Communitygithub.com

Bewegungsmuster

Produktionsreife Animationsmuster für React/Next.js – Button, Modal, Toast, Staffelung, Seitenübergänge, Exit-Animationen, Scroll und Layout – basierend auf motion-foundations-Tokens und Springs. Verwende es, wenn du ein bestimmtes UI-Element in React oder Next.js animierst.

Was ist Bewegungsmuster?

Dieses Skill bietet eine Sammlung von copy-paste-fähigen, produktionsreifen Animationsmustern für React/Next.js-Anwendungen, die mit `motion-foundations`-Tokens und Springs erstellt wurden. Es deckt die häufigsten UI-Animationen ab, darunter Buttons, Karten, Modals, Toasts, gestaffelte Listeneingänge, Seitenübergänge (Page Transitions) für den Next.js App Router, Scroll-Reveal-Effekte, Scroll-verknüpfte Fortschrittsbalken, ausklappbare Karten und Shared-Element-Übergänge. Das Skill befolgt strenge Regeln für Barrierefreiheit (Accessibility) und SSR-Sicherheit: Beispielsweise müssen alle bedingten Renderings in `AnimatePresence` mit einem `key` und einer `exit`-Animation eingeschlossen sein, Modals müssen Focus Trap, Escape-Key-Schließen und `role="dialog"` enthalten, und Staffelungsintervalle müssen zwischen 0,05s und 0,10s liegen. Es behandelt keine erweiterten Themen wie Drag-Interaktionen, SVG-Animationen oder Text-Animationen – diese sind Teil des verwandten Skills `motion-advanced`. Entwickler erhalten klare Entscheidungshilfen zur Auswahl des richtigen Musters, Anti-Patterns und vollständige Codebeispiele, die alle aus `motion-foundations` importieren, anstatt rohe Zahlen zu verwenden.

Funktioniert mit~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/motion-patterns

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Bewegungsmuster (Motion Patterns)

Copy-paste-Muster für die häufigsten UI-Animationen. Jedes Muster hier basiert auf motion-foundations-Tokens und Springs. Definiere hier keine neuen Dauer- oder Easing-Werte – importiere sie.

Wann aktivieren

  • Animation eines Buttons, einer Karte, eines Modals oder einer Toast-Benachrichtigung
  • Aufbau von Listeneingängen mit Staffelung (Stagger)
  • Einrichtung von Seitenübergängen im Next.js App Router
  • Hinzufügen von Ein- oder Ausgangsanimationen zu bedingten Inhalten
  • Implementierung von Scroll-Reveal, Scroll-verknüpftem Fortschritt oder klebrigen Story-Abschnitten
  • Bau von expandierenden Karten, Akkordeons oder Shared-Element-Übergängen

Ausgaben

Dieses Skill produziert:

  • Barrierefreie, SSR-sichere Animation für alle standardmäßigen UI-Komponenten
  • Mit AnimatePresence umschlossene bedingte Renderings mit korrektem Exit-Verhalten
  • Eine Page-Transition-Wrapper-Komponente für den Next.js App Router
  • Scroll-Reveal- und Scroll-verknüpfte Muster mittels useScroll + useTransform
  • Layout-Animationen (layout, layoutId) für expandierende und überblendende Elemente

Prinzipien

  • Jedes Muster importiert aus motion-foundations. Keine rohen Zahlen.
  • Jedes bedingte Rendering wird mit AnimatePresence und einem key umschlossen.
  • Exit-Animationen werden immer zusammen mit Enter-Animationen definiert – nie als nachträglicher Gedanke.
  • layout wird nur für kleine, isolierte Verschiebungen verwendet. Große Teilbäume erhalten explizite Transformationen.

Regeln

  1. Umschließe bedingte Renderings immer mit AnimatePresence und einem key auf dem direkten Kind. Ohne einen Schlüssel werden Exit-Animationen nie ausgelöst.
  2. Definiere immer exit, wenn du initial + animate definierst. Eine Animation ohne Exit ist unvollständig.
  3. Verwende mode="wait" für Seitenübergänge. Der Enter darf erst starten, wenn der Exit abgeschlossen ist.
  4. Verwende niemals layout auf Teilbäumen mit mehr als ~5 Kindern oder tief verschachteltem DOM. Verwende stattdessen explizite x-/y-Transformationen.
  5. Das Staffelungsintervall muss zwischen 0,05s und 0,10s liegen. Darunter wirkt es mechanisch; darüber träge.
  6. Modals müssen immer enthalten: Focus Trap, Escape-Taste zum Schließen, Scroll-Lock, role="dialog", aria-modal="true".
  7. Scroll-Reveals verwenden viewport={{ once: true }}. Wiederholungen beim Rausscrollen sind ablenkend, nicht informativ.
  8. Alle Token-Werte werden aus motion-foundations importiert. Keine inline-Zahlen.

Entscheidungshilfe

Das richtige Muster wählen

SituationMuster
Element erscheint / verschwindetAnimatePresence
Liste von Elementen, die nacheinander geladen werdenStagger-Varianten
Navigation zwischen RoutenPage-Transition-Wrapper
Element ändert seine Größe an Ort und Stellelayout-Prop
Selbes Element bewegt sich über Seitenkontexte hinweglayoutId
Element erscheint beim HineinscrollenwhileInView
Wert an die Scrollposition gebundenuseScroll + useTransform

Wann mode="wait" vs. mode="sync" verwenden

ModusVerwendung
waitSeitenübergänge, Inhaltswechsel (eines nach dem anderen)
syncGestapelte Benachrichtigungen, Listenelemente (Überlappung ist in Ordnung)
popLayoutElemente, die aus einer umfließenden Liste entfernt werden

Kernkonzepte

AnimatePresence-Vertrag

Drei Dinge müssen immer wahr sein:

  1. AnimatePresence umschließt das Bedingte
  2. Das direkte Kind hat einen key
  3. Das Kind hat eine exit-Prop

Fehlt eines dieser Elemente, schlägt die Exit-Animation still fehl.

layout vs. layoutId

  • layout – animiert die eigene Größen-/Positionsänderung des Elements an Ort und Stelle
  • layoutId – verknüpft zwei separate Elemente und blendet zwischen ihnen bei erneuten Renderings über

Verwende layout="position" für Text in einem expandierenden Container, um zu verhindern, dass der Textfluss animiert.

Code-Beispiele

Button-Feedback

"use client"
import { motion } from "motion/react"
import { springs, motionTokens } from "@/lib/motion-tokens"

<motion.button
  whileHover={{ scale: motionTokens.scale.pop }}
  whileTap={{ scale: motionTokens.scale.press }}
  transition={springs.snappy}
/>

Gestaffelte Liste

"use client"
import { motion } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"

const container = {
  hidden: {},
  visible: {
    transition: {
      staggerChildren: 0.08,   // innerhalb der 0,05–0,10-Regel
      delayChildren: 0.1,
    },
  },
}

const item = {
  hidden:  { opacity: 0, y: motionTokens.distance.md },
  visible: { opacity: 1, y: 0, transition: springs.gentle },
}

<motion.ul variants={container} initial="hidden" animate="visible">
  {items.map((i) => (
    <motion.li key={i.id} variants={item} />
  ))}
</motion.ul>

Modal

"use client"
import { motion, AnimatePresence } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"

// Umschließen an der Aufrufstelle:
// <AnimatePresence>{isOpen && <Modal key="modal" />}</AnimatePresence>

export function Modal({ onClose }: { onClose: () => void }) {
  return (
    <>
      {/* Overlay */}
      <motion.div
        className="fixed inset-0 bg-black/50"
        initial={{ opacity: 0 }}
        animate={{ opacity: 1 }}
        exit={{ opacity: 0 }}
        onClick={onClose}
      />

      {/* Panel – Barrierefreiheitsanforderungen: Focus Trap, Escape zum Schließen,
          Scroll-Lock, role="dialog", aria-modal="true" */}
      <motion.div
        role="dialog"
        aria-modal="true"
        className="fixed inset-x-4 top-1/2 -translate-y-1/2 rounded-xl bg-white p-6"
        initial={{
          opacity: 0,
          scale: motionTokens.scale.press,
          y: motionTokens.distance.sm,
        }}
        animate={{ opacity: 1, scale: 1, y: 0 }}
        exit={{
          opacity: 0,
          scale: motionTokens.scale.press,
          y: motionTokens.distance.sm,
        }}
        transition={springs.gentle}
      />
    </>
  )
}

Toast-Stack

"use client"
import { motion, AnimatePresence } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"

<AnimatePresence mode="sync">
  {toasts.map((t) => (
    <motion.div
      key={t.id}
      layout
      initial={{
        opacity: 0,
        x: motionTokens.distance.xl,
        scale: motionTokens.scale.subtle,
      }}
      animate={{ opacity: 1, x: 0, scale: 1 }}
      exit={{
        opacity: 0,
        x: motionTokens.distance.xl,
        scale: motionTokens.scale.subtle,
      }}
      transition={springs.snappy}
    />
  ))}
</AnimatePresence>

Seitenübergang (Next.js App Router)

// components/page-transition.tsx
"use client"
import { motion, AnimatePresence } from "motion/react"
import { usePathname } from "next/navigation"
import { motionTokens } from "@/lib/motion-tokens"

const variants = {
  initial: { opacity: 0, y: motionTokens.distance.sm },
  enter:   { opacity: 1, y: 0 },
  exit:    { opacity: 0, y: -motionTokens.distance.sm },
}

export function PageTransition({ children }: { children: React.ReactNode }) {
  const pathname = usePathname()
  return (
    <AnimatePresence mode="wait">
      <motion.div
        key={pathname}
        variants={variants}
        initial="initial"
        animate="enter"
        exit="exit"
        transition={{
          duration: motionTokens.duration.normal,
          ease: motionTokens.easing.smooth,
        }}
      >
        {children}
      </motion.div>
    </AnimatePresence>
  )
}

Scroll-Reveal

"use client"
import { motion } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"

<motion.div
  initial={{ opacity: 0, y: motionTokens.distance.lg }}
  whileInView={{ opacity: 1, y: 0 }}
  viewport={{ once: true, margin: "-80px" }}   // once: true – Regel 7
  transition={{ duration: motionTokens.duration.slow, ease: motionTokens.easing.smooth }}
/>

Scroll-Fortschrittsbalken

"use client"
import { motion, useScroll } from "motion/react"

export function ScrollProgress() {
  const { scrollYProgress } = useScroll()
  return (
    <motion.div
      className="fixed top-0 left-0 h-1 bg-indigo-500 origin-left w-full"
      style={{ scaleX: scrollYProgress }}
    />
  )
}

Expandierende Karte

"use client"
import { useState } from "react"
import { motion, AnimatePresence } from "motion/react"
import { springs, motionTokens } from "@/lib/motion-tokens"

export function ExpandingCard({ title, body }: { title: string; body: string }) {
  const [expanded, setExpanded] = useState(false)

  return (
    <motion.div layout onClick={() => setExpanded(!expanded)} className="cursor-pointer">
      {/* layout="position" verhindert, dass Textfluss animiert */}
      <motion.h2 layout="position" className="font-semibold">
        {title}
      </motion.h2>

      <AnimatePresence>
        {expanded && (
          <motion.p
            key="body"
            initial={{ opacity: 0 }}
            animate={{ opacity: 1 }}
            exit={{ opacity: 0 }}
            transition={{ duration: motionTokens.duration.fast }}
          >
            {body}
          </motion.p>
        )}
      </AnimatePresence>
    </motion.div>
  )
}

Shared-Element-Überblendung

// Quellkontext
<motion.img layoutId="hero-image" src={src} className="w-16 h-16 rounded" />

// Zielkontext (gleiches layoutId – motion übernimmt den Übergang)
<motion.img layoutId="hero-image" src={src} className="w-full rounded-xl" />

Akkordeon

<motion.div
  initial={false}
  animate={{ opacity: open ? 1 : 0, scaleY: open ? 1 : 0 }}
  style={{ transformOrigin: "top", overflow: "hidden" }}
  transition={{
    duration: motionTokens.duration.normal,
    ease: motionTokens.easing.smooth,
  }}
> {children}
</motion.div>

End-to-End-Beispiel

Eine gestaffelte Liste, die beim Mounten erscheint, bedingte Anwesenheit behandelt und reduzierte Bewegungen respektiert – kombiniert Tokens, Springs, AnimatePresence und den Barrierefreiheits-Hook aus motion-foundations:

"use client"
import { useState } from "react"
import { motion, AnimatePresence } from "motion/react"
import { motionTokens, springs } from "@/lib/motion-tokens"
import { useSafeMotion } from "@/hooks/use-reduced-motion"

const containerVariants = {
  hidden: {},
  visible: {
    transition: { staggerChildren: 0.08, delayChildren: 0.1 },
  },
}

function ListItem({ label, onRemove }: { label: string; onRemove: () => void }) {
  const safe = useSafeMotion(motionTokens.distance.sm)
  return (
    <motion.li
      variants={{
        hidden:  safe.initial,
        visible: safe.animate,
      }}
      exit={safe.exit}
      transition={springs.gentle}
      className="flex items-center justify-between p-3 rounded-lg bg-white shadow-sm"
    >
      <span>{label}</span>
      <button onClick={onRemove}>Entfernen</button>
    </motion.li>
  )
}

export function AnimatedList({ items, onRemove }: {
  items: { id: string; label: string }[]
  onRemove: (id: string) => void
}) {
  return (
    <motion.ul
      variants={containerVariants}
      initial="hidden"
      animate="visible"
      className="space-y-2"
    >
      <AnimatePresence mode="popLayout">
        {items.map((item) => (
          <ListItem
            key={item.id}
            label={item.label}
            onRemove={() => onRemove(item.id)}
          />
        ))}
      </AnimatePresence>
    </motion.ul>
  )
}

Einschränkungen / Nicht-Ziele

Dieses Skill deckt nicht ab:

  • Token- und Spring-Definitionen → siehe motion-foundations
  • Drag-Interaktionen, Wischgesten, neu anordenbare Listen → siehe motion-advanced
  • Text-Animationen (Wort-/Zeichen-Enthüllung, Zähler) → siehe motion-advanced
  • SVG-Pfadzeichnen oder Morphing → siehe motion-advanced
  • Benutzerdefinierte Animations-Hooks → siehe motion-advanced
  • CSS-only-Übergänge, die nicht motion/react verwenden

Anti-Patterns

Anti-PatternVerletzte RegelBehebung
AnimatePresence-Kind ohne keyRegel 1Stabilen key zum direkten Kind hinzufügen
initial + animate ohne exitRegel 2Immer alle drei zusammen definieren
Seitenübergang ohne mode="wait"Regel 3mode="wait" zu AnimatePresence hinzufügen
layout auf einer Liste mit 50 ElementenRegel 4mode="popLayout" oder explizite Transformationen verwenden
staggerChildren: 0.2 auf einer Liste mit 10 ElementenRegel 5Auf 0,08–0,10 begrenzen
Modal ohne Focus TrapRegel 6focus-trap-react oder Radix Dialog hinzufügen
whileInView ohne viewport={{ once: true }}Regel 7Wiederholte Eingänge lenken ab, informieren nicht
transition={{ duration: 0.3 }} inlineRegel 8motionTokens.duration.normal verwenden

Verwandte Skills

  • motion-foundations – definiert alle Tokens, Springs, den useSafeMotion-Hook und SSR-Guards, die jedes Muster hier importiert. Muss zuerst eingerichtet werden.
  • motion-advanced – erweitert diese Muster um Drag, Gesten, SVG, Text, benutzerdefinierte Hooks und imperative Sequenzierung. Definiert keine Muster aus diesem Skill neu.

Individual skills in this repo

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

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

Verwandte Skills