Communitygithub.com

503496348-ops/mischief-production

React / Next.js용 고급 모션 패턴 — 드래그 앤 드롭, 제스처, 텍스트 애니메이션, SVG 경로 그리기, 커스텀 훅, 명령형 시퀀스(useAnimate), 로더 및 전체 API 결정 트리. motion-foundations 필요.

mischief-production란 무엇인가요?

이 스킬은 `motion-patterns`로 충분하지 않을 때 사용하는 React 및 Next.js용 고급 애니메이션 패턴 라이브러리입니다. `motion-foundations`가 먼저 설정되어 있어야 하며, 드래그 투 디스미스 시트, 스와이프 제스처, 재정렬 가능 목록, 단어/문자별 텍스트 애니메이션, SVG 경로 그리기, 아이콘 모핑, 원형 진행률 표시기, `useScrollReveal` 및 `useLongPress`와 같은 커스텀 훅, `useAnimate`를 사용한 명령형 시퀀스, 스피너, 심머, 펄스 도트 및 버튼 로딩 상태와 같은 로더 컴포넌트를 생성합니다. 물리 기반 모션(useSpring)을 우선시하며, `useMotionValue`와 `useTransform`을 사용하여 불필요한 리렌더링 없이 파생 값을 계산합니다. `useAnimate`를 사용한 명령형 시퀀스는 인터럽트에 안전하며, 탭이 백그라운드에 있을 때 무한 애니메이션을 일시 중지하고, 모든 토큰 값을 `motion-foundations`에서 가져옵니다. Claude Code, Cursor, Codex와 같은 AI 코딩 에이전트가 상호작용적이고 물리 기반의 복잡한 UI 애니메이션을 구축할 때 사용하기에 적합합니다.

지원 대상~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/503496348-ops/mischief-production/tree/HEAD/skills/ecc-motion-advanced

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Motion Advanced

복잡하고 상호작용적이며 물리 기반의 애니메이션 패턴. motion-foundations가 먼저 설정되어 있어야 합니다. motion-patterns로 충분하지 않을 때 사용하세요.

활성화 시기

  • 드래그 투 디스미스 시트, 스와이프 제스처 또는 재정렬 가능 목록 구축
  • 단어별, 문자별 텍스트 애니메이션 또는 실시간 카운터
  • SVG 경로 그리기, 아이콘 모핑 또는 원형 진행률 애니메이션
  • 커스텀 애니메이션 훅 작성 (useScrollReveal, 마그네틱 버튼, 커서 팔로워)
  • useAnimate로 다단계 시퀀스를 명령형으로 연결
  • 스피너, 심머 스켈레톤, 펄스 표시기 또는 버튼 로딩 상태 구축

결과물

이 스킬은 다음을 생성합니다:

  • 드래그 상호작용: 드래그 가능 카드, 드래그 투 디스미스 시트, Reorder.Group 목록
  • 제스처 훅: 스와이프 감지, 길게 누르기, 핀치 개요
  • 텍스트 애니메이션 컴포넌트: 단어 나타내기, 문자 타자기, 숫자 카운터
  • SVG 애니메이션: 경로 그리기, 아이콘 모핑, 스트로크 진행률 링
  • 커스텀 훅: useScrollReveal, useHoverScale, useNavigationDirection, useInViewOnce
  • 명령형 시퀀스: 인터럽트 안전 async/await와 함께 useAnimate 사용
  • 로더 컴포넌트: 스피너, 심머, 펄스 도트, 진행률 표시줄, 버튼 로딩 상태

원칙

  • 물리 기반 모션 (useSpring, springs.*)은 직접 조작 시 항상 지속 시간 기반보다 더 자연스럽습니다.
  • useMotionValue + useTransform은 리렌더링을 트리거하지 않고 파생 값을 계산합니다.
  • useAnimate 시퀀스는 명령형이며 인터럽트에 안전합니다. 실행 중에 animate()를 호출하면 이전 애니메이션이 자동으로 취소됩니다.
  • 모션 값 (useMotionValue, useSpring)은 SSR 안전하며 수화 오류를 일으키지 않습니다.

규칙

  1. 드래그 상호작용은 마우스뿐만 아니라 터치 기기에서도 테스트해야 합니다. drag prop은 둘 다에서 작동하지만 느낌과 임계값이 다릅니다.
  2. 무한 애니메이션은 document.visibilityState === "hidden"일 때 일시 중지되어야 합니다. 백그라운드 탭은 GPU/CPU를 소비해서는 안 됩니다.
  3. 스와이프 임계값은 명시적이어야 합니다. 속도만으로 의도를 추론하지 마십시오. offset + velocity 검사를 결합하십시오.
  4. useAnimate 범위 참조는 마운트된 DOM 요소에 연결되어야 합니다. 마운트 전에 animate()를 호출하면 자동으로 실패합니다.
  5. 모션 값은 렌더링 시 다시 생성되어서는 안 됩니다. 컴포넌트 본문 내부의 useMotionValue(0)는 올바르지만, 렌더링에서 new MotionValue(0)는 올바르지 않습니다.
  6. 모든 토큰 값은 motion-foundations에서 가져옵니다. 인라인 숫자는 없습니다.
  7. 커스텀 훅은 정리를 처리해야 합니다. 모든 window.addEventListener는 useEffect 반환에 일치하는 removeEventListener가 필요합니다.
  8. SVG 모핑은 동일한 경로 명령 수가 필요합니다. 명령 구조가 다른 경로는 보간 대신 스냅됩니다.

결정 가이드

올바른 고급 API 선택

시나리오API
릴리스 시 물리 효과가 있는 드래그drag + dragTransition: springs.release
정렬된 드래그 투 리오더 목록Reorder.Group + Reorder.Item
드래그 오프셋에서 닫기drag="y" + onDragEnd 오프셋 검사
왼쪽/오른쪽 스와이프drag="x" + onDragEnd 오프셋 검사
길게 누르기useLongPress 훅
시간이 지남에 따라 평활화된 값useSpring
다른 값에서 파생된 값useTransform
다단계 시퀀스async/await와 함께 useAnimate 사용
일회성 명령형 애니메이션motion에서 animate()
단어별로 입력되는 텍스트inline-block 범위에서 스태거
SVG 그리기 켜기pathLength 0 → 1
SVG 모프d 속성 트위닝 (동일한 명령)
원형 진행률strokeDashoffset 트위닝

useSpring vs 스프링 전환 사용 시기

useSpringtransition: springs.*
사용 용도커서 팔로워, 포인터 추적 값개별 상태 변경
업데이트연속, 모든 프레임에서상태 변경에 의해 트리거됨
중단부드러움 — 물리 효과가 속도에서 시작됨현재 값에서 다시 시작됨

핵심 개념

useMotionValue + useTransform

리렌더링 없는 반응형 계산:

const x = useMotionValue(0)
const opacity = useTransform(x, [-200, 0, 200], [0, 1, 0])
// x가 변경됨에 따라 opacity는 모든 프레임에서 업데이트됩니다 — setState 없음, 리렌더링 없음

useAnimate

[scope, animate]를 반환합니다. 범위 참조는 DOM 요소에 연결되어야 합니다. animate() 호출은 인터럽트에 안전합니다. 실행 중에 호출하면 이전 실행이 취소됩니다.

const [scope, animate] = useAnimate()

async function play() {
  await animate(".step-1", { opacity: 1 }, { duration: 0.3 })
  await animate(".step-2", { x: 0 },       { duration: 0.4 })
        animate(".step-3", { scale: 1 },    { duration: 0.25 })  // fire and forget
}

return <div ref={scope}>...</div>

코드 예제

드래그 가능 카드

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

<motion.div
  drag
  dragConstraints={{ left: -100, right: 100, top: -100, bottom: 100 }}
  dragElastic={0.1}
  whileDrag={{
    scale: motionTokens.scale.pop,
    boxShadow: "0 16px 40px rgba(0,0,0,0.2)",
  }}
  dragTransition={springs.release}
/>

드래그 투 디스미스 시트

"use client"
import { motion, useMotionValue, useTransform } from "motion/react"

export function BottomSheet({ onClose }: { onClose: () => void }) {
  const y = useMotionValue(0)
  const opacity = useTransform(y, [0, 200], [1, 0])

  return (
    <motion.div
      drag="y"
      dragConstraints={{ top: 0 }}
      style={{ y, opacity }}
      onDragEnd={(_, info) => {
        // 규칙 3: offset + velocity 결합
        if (info.offset.y > 120 || info.velocity.y > 500) onClose()
      }}
    />
  )
}

재정렬 가능 목록

"use client"
import { Reorder } from "motion/react"

export function SortableList() {
  const [items, setItems] = useState(initialItems)
  return (
    <Reorder.Group axis="y" values={items} onReorder={setItems}>
      {items.map((item) => (
        <Reorder.Item key={item.id} value={item}>
          {item.label}
        </Reorder.Item>
      ))}
    </Reorder.Group>
  )
}

스와이프 감지

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

const OFFSET_THRESHOLD  = 50
const VELOCITY_THRESHOLD = 300

<motion.div
  drag="x"
  dragConstraints={{ left: 0, right: 0 }}
  onDragEnd={(_, info) => {
    const swipedRight = info.offset.x > OFFSET_THRESHOLD  || info.velocity.x > VELOCITY_THRESHOLD
    const swipedLeft  = info.offset.x < -OFFSET_THRESHOLD || info.velocity.x < -VELOCITY_THRESHOLD
    if (swipedRight) onSwipeRight()
    if (swipedLeft)  onSwipeLeft()
  }}
/>

길게 누르기 훅

import { useRef } from "react"

export function useLongPress(callback: () => void, ms = 600) {
  const timerRef = useRef<ReturnType<typeof setTimeout>>()
  return {
    onPointerDown:  () => { timerRef.current = setTimeout(callback, ms) },
    onPointerUp:    () => clearTimeout(timerRef.current),
    onPointerLeave: () => clearTimeout(timerRef.current),
  }
}

단어별 표시

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

export function AnimatedText({ text }: { text: string }) {
  return (
    <motion.p
      variants={{ visible: { transition: { staggerChildren: 0.05 } } }}
      initial="hidden"
      animate="visible"
    >
      {text.split(" ").map((word, i) => (
        <motion.span
          key={i}
          className="inline-block mr-1"
          variants={{
            hidden:  { opacity: 0, y: 12 },
            visible: { opacity: 1, y: 0, transition: springs.gentle },
          }}
        >
          {word}
        </motion.span>
      ))}
    </motion.p>
  )
}

숫자 카운터

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

export function Counter({ to }: { to: number }) {
  const nodeRef = useRef<HTMLSpanElement>(null)

  useEffect(() => {
    const controls = animate(0, to, {
      duration: motionTokens.duration.crawl,
      ease: motionTokens.easing.smooth,
      onUpdate: (v) => {
        if (nodeRef.current) nodeRef.current.textContent = Math.round(v).toString()
      },
    })
    return controls.stop   // 규칙 7: 정리
  }, [to])

  return <span ref={nodeRef} />
}

SVG 경로 그리기

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

<motion.path
  d="M 0 100 Q 50 0 100 100"
  initial={{ pathLength: 0, opacity: 0 }}
  animate={{ pathLength: 1, opacity: 1 }}
  transition={{ duration: motionTokens.duration.slow, ease: motionTokens.easing.smooth }}
/>

스트로크 진행률 링

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

const CIRCUMFERENCE = 2 * Math.PI * 40   // r=40

export function ProgressRing({ progress }: { progress: number }) {
  return (
    <svg width="100" height="100" viewBox="0 0 100 100">
      <circle cx="50" cy="50" r="40" fill="none" stroke="#e5e7eb" strokeWidth="8" />
      <motion.circle
        cx="50" cy="50" r="40"
        fill="none" stroke="#6366f1" strokeWidth="8"
        strokeLinecap="round"
        strokeDasharray={CIRCUMFERENCE}
        animate={{ strokeDashoffset: CIRCUMFERENCE - (progress / 100) * CIRCUMFERENCE }}
        transition={{ duration: motionTokens.duration.normal, ease: motionTokens.easing.smooth }}
        style={{ rotate: -90, transformOrigin: "center" }}
      />
    </svg>
  )
}

useScrollReveal 훅

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

export function useScrollReveal() {
  const ref = useRef(null)
  const { scrollYProgress } = useScroll({ target: ref, offset: ["start end", "end start"] })
  const opacity = useTransform(scrollYProgress, [0, 0.3], [0, 1])
  const y       = useTransform(scrollYProgress, [0, 0.3], [motionTokens.distance.lg, 0])
  return { ref, style: { opacity, y } }
}

// 사용법
const { ref, style } = useScrollReveal()
<motion.section ref={ref} style={style} />

커서 팔로워

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

export function CursorFollower() {
  const x = useMotionValue(-100)
  const y = useMotionValue(-100)
  const sx = useSpring(x, springs.gentle)
  const sy = useSpring(y, springs.gentle)

  useEffect(() => {
    const move = (e: MouseEvent) => { x.set(e.clientX); y.set(e.clientY) }
    window.addEventListener("mousemove", move)
    return () => window.removeEventListener("mousemove", move)   // 규칙 7
  }, [])

  return (
    <motion.div
      className="fixed top-0 left-0 w-6 h-6 rounded-full bg-indigo-500
                 pointer-events-none -translate-x-1/2 -translate-y-1/2 z-50"
      style={{ x: sx, y: sy }}
    />
  )
}

심머 스켈레톤

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

export function ShimmerSkeleton({ className = "" }: { className?: string }) {
  const controls = useAnimation()

  useEffect(() => {
    const play = () =>
      controls.start({
        x: ["-100%", "100%"],
        transition: {
          repeat: Infinity,
          duration: motionTokens.duration.crawl,
          ease: motionTokens.easing.linear,
        },
      })

    const handleVisibility = () => {
      if (document.visibilityState === "hidden") controls.stop()
      else void play()
    }

    void play()
    document.addEventListener("visibilitychange", handleVisibility)
    return () => {
      controls.stop()
      document.removeEventListener("visibilitychange", handleVisibility)
    }
  }, [controls])

  return (
    <div className={`relative overflow-hidden bg-gray-200 rounded ${className}`}>
      <motion.div
        className="absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent"
        initial={{ x: "-100%" }}
        animate={controls}
      />
    </div>
  )
}

버튼 로딩 상태

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

export function LoadingButton({
  loading,
  label,
  onClick,
}: {
  loading: boolean
  label: string
  onClick: () => void
}) {
  return (
    <motion.button
      onClick={onClick}
      animate={{ opacity: loading ? 0.7 : 1 }}
      whileTap={loading ? {} : { scale: motionTokens.scale.press }}
      transition={springs.snappy}
      disabled={loading}
    >
      <AnimatePresence mode="wait">
        {loading ? (
          <motion.span
            key="loading"
            initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}
            transition={{ duration: motionTokens.duration.fast }}
          >
            …
          </motion.span>
        ) : (
          <motion.span
            key="label"
            initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}
            transition={{ duration: motionTokens.duration.fast }}
          >
            {label}
          </motion.span>
        )}
      </AnimatePresence>
    </motion.button>
  )
}

가시성 일시 중지가 있는 무한 애니메이션

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

export function PulseDot() {
  const controls = useAnimation()

  useEffect(() => {
    const pulse = () =>
      controls.start({
        scale: [1, 1.4, 1],
        opacity: [1, 0.6, 1],
        transition: { repeat: Infinity, duration: motionTokens.duration.crawl },
      })

    // 규칙 2: 탭이 숨겨져 있을 때 일시 중지
    const handleVisibility = () => {
      if (document.visibilityState === "hidden") controls.stop()
      else void pulse()
    }

    void pulse()
    document.addEventListener("visibilitychange", handleVisibility)
    return () => {
      controls.stop()
      document.removeEventListener("visibilitychange", handleVisibility)
    }
  }, [controls])

  return <motion.span animate={controls} />
}

MagneticButton (커스텀 훅 패턴)

"use client"
import { useRef, useCallback } from "react"
import { motion, useMotionValue, useSpring } from "motion/react"
import { springs } from "@/lib/motion-tokens"

export function MagneticButton({ children }: { children: React.ReactNode }) {
  const ref = useRef<HTMLDivElement>(null)
  const x = useMotionValue(0)
  const y = useMotionValue(0)
  const sx = useSpring(x, springs.gentle)
  const sy = useSpring(y, springs.gentle)

  const handlePointerMove = useCallback((e: React.PointerEvent) => {
    const rect = ref.current?.getBoundingClientRect()
    if (!rect) return
    const cx = rect.left + rect.width / 2
    const cy = rect.top + rect.height / 2
    x.set((e.clientX - cx) * 0.3)
    y.set((e.clientY - cy) * 0.3)
  }, [])

  const handlePointerLeave = useCallback(() => {
    x.set(0)
    y.set(0)
  }, [])

  return (
    <motion.div
      ref={ref}
      onPointerMove={handlePointerMove}
      onPointerLeave={handlePointerLeave}
      style={{ x: sx, y: sy }}
    >
      {children}
    </motion.div>
  )
}

Individual skills in this repo

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

503496348-ops/mischief-production

Use this skill when inspecting Blender characters, rigs, poses, animation retargeting, ground contact, facing direction, or model-vs-motion alignment where screenshots alone are not enough.

503496348-ops/mischief-production

Build reusable Manim explainers for technical concepts, graphs, system diagrams, and product walkthroughs, then hand off to the wider HCP video stack if needed. Use when the user wants a clean animated explainer rather than a generic talking-head script.

503496348-ops/mischief-production

Motion tokens, spring presets, performance rules, device adaptation, accessibility enforcement, and SSR safety for React / Next.js using motion/react. Foundation layer — all other motion skills depend on this.

503496348-ops/mischief-production

Production-ready animation patterns for React / Next.js — button, modal, toast, stagger, page transitions, exit animations, scroll, and layout — built on motion-foundations tokens and springs.

503496348-ops/mischief-production

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

503496348-ops/mischief-production

Best practices for Remotion - Video creation in React. 29 domain-specific rules covering 3D, animations, audio, captions, charts, transitions, and more.

503496348-ops/mischief-production

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

관련 스킬