Communitygithub.com

SVG 애니메이션

아이콘, 일러스트레이션, 로고 및 데이터 마크에 적합한 선명하고 가벼우며 무한히 확장 가능한 벡터 모션을 제공합니다. CSS, SMIL, GSAP을 사용하여 획 그리기, 패스 모핑, 경로 이동, 그라디언트/필터 애니메이션을 구현합니다.

SVG 애니메이션란 무엇인가요?

이 스킬은 SVG 애니메이션을 구현하는 종합 가이드입니다. 아이콘, 로고, 일러스트레이션 등 벡터 그래픽에 동적인 움직임을 부여할 때 사용합니다. 세 가지 주요 애니메이션 방식을 지원합니다. CSS는 간단한 선언적 애니메이션에, SMIL은 추가 라이브러리 없이 SVG 내부에서 자체 애니메이션을 구현할 때, GSAP는 복잡한 제어와 모핑 등 고급 기능이 필요할 때 각각 선택합니다. 핵심 기술로는 `stroke-dashoffset`을 이용한 획 그리기 애니메이션, `GSAP MorphSVG` 또는 `Flubber`를 사용한 패스 모핑, `GSAP MotionPath`나 CSS `offset-path`, 또는 SMIL `<animateMotion>`을 통한 경로 이동 애니메이션, 그리고 그라디언트와 필터의 애니메이션을 다룹니다. 또한 SVGO 최적화 설정, 접근성(`prefers-reduced-motion` 준수), 독립 실행형 HTML 파일 제공 방법, 타임라인 특정 순간을 캡처하는 seek harness 등 실무에 필요한 구현 및 검증까지 안내합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/nehakanjamala/personal_website/tree/HEAD/.agents/skills/svg-animation

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

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

문서

SVG 애니메이션은(는) 무엇을 하나요?

선명하고 가벼우며 무한히 확장 가능한 벡터 모션 — 아이콘, 일러스트레이션, 로고 및 데이터 마크에 이상적입니다. SVG는 CSS(선언적, 간단함), SMIL(SVG 내부 <animate>), JS(GSAP/Web Animations, 제어 및 모핑 용이) 세 가지 방식으로 애니메이션을 적용할 수 있습니다. 작업별로 선택하세요. 아래 기법에서 어떤 방식을 사용하는지 명시합니다.

사용 시기

  • 아이콘, 일러스트레이션, 서명, 지도의 획 "그리기"
  • 도형/패스 모핑 및 애니메이션 아이콘 상태 변경(메뉴 ↔ 닫기, 재생 ↔ 일시정지)
  • 경로를 따라 요소 이동(모션 패스)
  • 애니메이션 그라디언트, 필터(광선, 변위) 및 애니메이션 로고

핵심 기법

획 그리기 (기본)

대시 배열을 패스 길이만큼 설정하고 전체를 오프셋(보이지 않게)한 다음 오프셋을 0으로 애니메이션합니다.

.path {
  stroke-dasharray: var(--len);
  stroke-dashoffset: var(--len);
  animation: draw 1.4s ease forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

길이 구하기:

  • JS(가장 신뢰할 수 있음): const len = path.getTotalLength(); path.style.setProperty("--len", len);
  • JS 없는 트릭: <path>에 pathLength="1"을 설정한 후 stroke-dasharray: 1; stroke-dashoffset: 1;로 하고 0으로 애니메이션합니다. 이렇게 하면 모든 패스를 0–1 길이로 정규화하여 측정이 필요 없습니다.

오프셋을 0에서 다시 len으로 애니메이션하여 지우기(역방향)를 수행합니다. 여러 패스에 animation-delay를 사용하여 순차적으로 애니메이션합니다. 그리기 방향은 패스의 점 순서를 따릅니다. "거꾸로" 그려지면 편집기에서 방향을 반전하거나 오프셋 부호를 반전시킵니다.

하나의 패스를 다른 패스로 모핑

패스는 점 단위로 보간되므로, 기본 모핑을 위해서는 두 d 속성이 동일한 개수와 유형의 명령을 가져야 합니다. 두 가지 강력한 방법:

  • GSAP MorphSVG(GSAP 3.12부터 무료) — 불일치하는 점 개수를 자동으로 처리하고 적절한 매핑을 찾습니다:
gsap.registerPlugin(MorphSVGPlugin);
gsap.to("#start", { morphSVG: "#end", duration: 0.8, ease: "power2.inOut" });
// 모든 도형을 모핑 가능한 패스로 변환:
MorphSVGPlugin.convertToPath("circle, rect, ellipse, line, polygon");
  • Flubber(소형 독립 실행형 라이브러리) — GSAP 없이 보간기를 생성하며 React/Framer Motion과 잘 어울립니다:
import { interpolate } from "flubber";
const interpolator = interpolate(pathA, pathB, { maxSegmentLength: 2 });
// interpolator(0) === pathA, interpolator(1) === pathB; t 값을 트윈에 공급합니다.

수작업 모핑(아이콘 토글)의 경우, 두 패스를 동일한 명령 구조로 유지하고 Web Animations 또는 CSS를 통해 d를 직접 애니메이션합니다(최신 브라우저에서는 path("...")를 통해 d 애니메이션이 가능합니다).

경로를 따른 모션

  • GSAP MotionPath(선호 — 제어, 정렬, 스크럽):
gsap.registerPlugin(MotionPathPlugin);
gsap.to("#rocket", {
  duration: 4, repeat: -1, ease: "none",
  motionPath: { path: "#track", align: "#track", autoRotate: true, alignOrigin: [0.5, 0.5] },
});

autoRotate: true는 객체를 패스 접선 방향으로 정렬합니다. align은 좌표를 패스 요소에 상대적으로 만듭니다.

  • SMIL(JS 불필요):
<path id="track" d="M10,80 C40,10 120,10 150,80" fill="none"/>
<circle r="6" fill="#3b82f6">
  <animateMotion dur="3s" repeatCount="indefinite" rotate="auto">
    <mpath href="#track"/>
  </animateMotion>
</circle>
  • CSS offset-path(최신, 선언적): offset-path: path("M10,80 C..."); animation: move 3s linear infinite;와 함께 @keyframes move { to { offset-distance: 100%; } } 및 offset-rotate: auto를 사용합니다.

애니메이션 그라디언트 및 필터

그라디언트: gradientTransform 또는 정지점 오프셋을 애니메이션합니다. 광택 효과:

<linearGradient id="sheen">
  <stop offset="0%"  stop-color="#fff" stop-opacity="0"/>
  <stop offset="50%" stop-color="#fff" stop-opacity=".8"/>
  <stop offset="100%" stop-color="#fff" stop-opacity="0"/>
  <animateTransform attributeName="gradientTransform" type="translate"
    from="-1 0" to="1 0" dur="2s" repeatCount="indefinite"/>
</linearGradient>

필터: 끈적/흔들림 효과를 위한 feDisplacementMap scale 애니메이션, 초점 변경을 위한 feGaussianBlur stdDeviation 애니메이션, 또는 광선 효과를 위한 feColorMatrix/feFlood 애니메이션. 필터는 렌더링 부하가 크므로 신중하게 애니메이션하고 가능하면 transform/opacity를 선호합니다.

구현 선택 (빠른 결정)

필요사용
단일 선언적 그리기/페이드CSS
자체 포함, JS 번들 불필요SMIL (SVG 내 <animate*>)
조정, 스크러블, 스크롤 연동GSAP
불일치 점 모핑GSAP MorphSVG 또는 Flubber
회전이 있는 경로 따라가기GSAP MotionPath / CSS offset-path

SMIL 주의사항: IE/구형 Edge에서 지원되지 않으며 과거에 폐기 예정이었습니다. 최대 호환성 또는 스크롤 동기화가 필요하면 CSS나 JS를 선호하세요. SMIL은 상시 업데이트 브라우저에서 자체 포함된 아이콘 에셋에는 여전히 괜찮습니다.

제작 및 최적화

  • SVGO로 빌드/정리: viewBox 유지, 편집기 메타데이터 제거, 하지만 CSS/JS/SMIL에서 참조하는 ID를 변경하는 cleanupIds/removeViewBox 및 모든 플러그인은 비활성화합니다. 개별 하위 패스나 도형을 애니메이션하는 경우 mergePaths와 convertShapeToPath를 비활성화합니다.
  • SVG를 DOM에 인라인으로 배치합니다(<img src> 아님). 그래야 CSS/JS가 내부 요소에 접근할 수 있습니다. <img>에 포함된 SVG는 내부 SMIL/CSS를 통해서만 자체 애니메이션이 가능합니다.
  • 명시적인 viewBox를 설정하고 고정 width/height를 피하여 에셋이 유연하게 크기 조절되도록 합니다.
  • 그리기 애니메이션의 경우 패스가 실제 획(fill:none; stroke:...)인지 확인합니다. 채워진 윤곽선이 아닌지 확인하세요. dashoffset은 획에만 영향을 미칩니다.
  • prefers-reduced-motion을 존중합니다: 반복/큰 모션을 제한하고 정적 최종 상태를 유지합니다.

전달 및 검증 (독립 실행형 HTML)

패키지된 도우미(scripts/): scripts/seek-shot.sh anim.html 0 1.5 3은 ?t=N 하네스를 고정하고 각 순간을 스크린샷으로 캡처합니다. scripts/contact-sheet.sh sheet.png frame-*.png는 한눈에 검토할 수 있도록 타일링합니다. scripts/README.md를 참조하세요.

자체 포함된 아이콘/로고/그리기 애니메이션의 경우 결과물은 브라우저에서 직접 열 수 있는 HTML 파일 하나입니다. 마크업에 SVG를 인라인으로 포함하고, 하나의 메커니즘으로 애니메이션을 구동하며, 빌드 단계가 없습니다. 벡터 에셋에 적합한 방식입니다. 번들러를 사용할 필요가 없습니다.

출력 계약:

  • .html 파일 하나: 인라인 <svg>, plus CSS @keyframes / CDN에서 GSAP를 포함한 <script> / SMIL <animate*> — 드라이버 하나를 선택합니다.
  • 해당 드라이버와 일치하는 seek 하네스를 포함하여 언제든지 특정 순간을 고정하여 스크린샷을 찍을 수 있습니다.

Seek 하네스 — 정확한 순간 고정. ?t=N은 탐색 후 일시 정지하여 스크린샷이 정지된 프레임을 캡처합니다. SVG 애니메이션 방식과 일치하는 메커니즘을 사용합니다:

<script>
  const t = new URLSearchParams(location.search).get("t");
  if (t !== null) {
    const N = parseFloat(t);
    // SMIL: SVG 자체 시계를 일시 정지하고 스크럽
    const svg = document.querySelector("svg");
    svg.pauseAnimations(); svg.setCurrentTime(N);
    // CSS @keyframes 그리기: el.style.animationDelay=(-N)+"s"; el.style.animationPlayState="paused";
    // GSAP 타임라인: tl.pause(); tl.seek(N);
  }
  window.__ready = true;
</script>

검증 루프 — 렌더링 → 고정 → 스크린샷 → 확인: 시작/중간/끝(?t=0, ?t=<dur/2>, ?t=<dur>)에서 파일을 열고 각각 스크린샷을 찍어 정확도(획이 올바른 방향으로 그려지는지, 모핑 끝점이 깨끗한지)와 아티팩트(viewBox로 인한 패스 잘림, 오래된 dashoffset으로 인한 획 사라짐, FOUC, 모핑 이음새의 버벅임)를 확인합니다. 모든 헤드리스 도구를 사용할 수 있습니다:

npx playwright screenshot --wait-for-timeout=500 "file://$PWD/icon.html?t=0.7" frame-mid.png

마무리 전 확인 사항:

  1. 독립 실행형으로 열림 — 콘솔 오류 없음, 인라인 SVG 접근 가능, CDN(있는 경우) 로드됨.
  2. 드라이버에 맞는 seek 메커니즘이 결정적인 프레임을 고정함.
  3. 시작/중간/끝에서 스크린샷 확인 — 요구 사항과 일치하며, 잘리거나 viewBox를 벗어난 획이 없음.
  4. prefers-reduced-motion 존중됨 — 반복/큰 모션 제한, 정적 최종 상태 유지.
  5. 이징이 의도적임 — ease/GSAP 이즈가 의도적으로 선택되었고, 우발적인 linear 그리기가 없음.

참조 파일

  • references/svg-techniques.md — 전체 dashoffset 수학 및 getTotalLength 함정, pathLength="1" 정규화, GSAP MorphSVG vs Flubber 결정 가이드(코드 포함), 아이콘 토글 모핑(햄버거↔닫기), MotionPath/offset-path 세부 정보, SMIL-vs-CSS-vs-JS 트레이드오프, 애니메이션에 최적화된 SVGO 구성.

Individual skills in this repo

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

nehakanjamala/personal_website

This skill should be used when the user asks to "fix janky CSS animation", "make animation 60fps", "stop layout thrashing", "animate width/height/top/left smoothly", "convert animation to transform", "animate box-shadow performantly", "animate height auto", "FLIP animation", or "why is my scroll/hover animation choppy".

nehakanjamala/personal_website

This skill should be used when the user asks to "respect prefers-reduced-motion", "honor reduced motion", "make my animations accessible", "fix vestibular / motion-sickness issues", "add a useReducedMotion hook", "gate GSAP / Framer Motion / Lenis for reduced motion", or "meet WCAG 2.3.3 / C39". Provides tiered (not all-or-nothing) reduced-motion patterns in CSS and JS.

nehakanjamala/personal_website

Create, modify, debug, and deploy Apify Actors, and write their input and output schemas. Use when building an Actor from scratch, changing or troubleshooting Actor code, generating or updating .actor schema files, or pushing an Actor to the Apify platform. To wrap an existing non-Actor project, use apify-actorization instead.

nehakanjamala/personal_website

Convert existing projects into Apify Actors - serverless cloud programs. Actorize JavaScript/TypeScript (SDK with Actor.init/exit), Python (async context manager), or any language (CLI wrapper). Use when migrating code to Apify, wrapping CLI tools as Actors, or adding Actor SDK to existing projects.

nehakanjamala/personal_website

Deprecated. Output schema generation moved to the apify-actor-development skill; prefer that skill whenever it is available.

nehakanjamala/personal_website

Design and build an official Apify integration for a company's product - workflow-automation apps (Zapier/n8n-style), AI agent plugins (coding-agent skills+MCP bundles or OpenClaw/Hermes-style harnesses), AI framework packages (LangChain/LlamaIndex-style), or direct application clients via apify-client. Use when planning, creating, or reviewing an integration that exposes Apify Actors, runs, datasets, or key-value stores inside another product.

nehakanjamala/personal_website

Universal AI-powered web scraper for any platform. Scrape data from Instagram, Facebook, TikTok, YouTube, LinkedIn, X/Twitter, Google Maps, Google Search, Google Trends, Reddit, Airbnb, Yelp, and 15+ more platforms. Use for lead generation, brand monitoring, competitor analysis, influencer discovery, trend research, content analytics, audience analysis, review analysis, SEO intelligence, recruitment, or any data extraction task.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a glassmorphism effect", "frosted glass UI", "Apple liquid glass style", "frosted blur card", "translucent glass panel animation", "make a frosted nav bar", "build a glass modal/dialog", "animate a glass card on hover", or "add a refracting liquid-glass hero". Covers frosted translucent panels with backdrop-filter blur, edge/specular highlights, SVG liquid-glass refraction, motion on hover/scroll/enter, and accessible reduced-transparency fallbacks.

nehakanjamala/personal_website

This skill should be used when the user asks to "build a scroll animation", "add ScrollTrigger", "pin a section while scrolling", "scrub an animation to scroll", "create a hero timeline", "do a horizontal scroll section", "split text and animate words", "animate a layout change with GSAP Flip", "sync ScrollTrigger with Lenis", "Lenis smooth scroll jittery", "ScrollTrigger markers drift", "ScrollTrigger pins break with Lenis/Locomotive", or "set up smooth scroll with GSAP pinning". Covers GSAP timelines, ScrollTrigger, SplitText, Flip, and Lenis/Locomotive smooth-scroll sync for code-driven web motion.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a Lottie animation", "play a .lottie or .json animation", "integrate a Bodymovin/After Effects animation on web or mobile", "control Lottie playback / segments", "make a scroll-driven Lottie", "recolor a Lottie at runtime", or "export an AE animation to Lottie". Covers dotLottie/lottie-web integration, playback control, interactivity, theming, and the AE export checklist.

nehakanjamala/personal_website

This skill should be used when the user asks to "add a hover/press effect", "animate a toggle or switch", "build an animated like button", "make a toast/snackbar slide in", "animate a drawer or modal", "animate list reordering or add/remove", "do a shared-element layout transition", or "polish UI feedback". Covers UI motion with Framer Motion (motion/react) and modern CSS.

nehakanjamala/personal_website

This skill should be used when the user asks to "animate page or route transitions", "add a page transition or crossfade between views", "animate route changes in Next.js App Router", "use the View Transitions API", "AnimatePresence exit doesn't fire on navigation", or "Framer Motion exit animation not working / exit animation before unmount in Next.js". Covers enter/exit page-transition animation with the View Transitions API and Framer Motion, for Next.js App Router and general SPA routing.

nehakanjamala/personal_website

Scrape web pages using Scrapling with anti-bot bypass (like Cloudflare Turnstile), stealth headless browsing, spiders framework, adaptive scraping, and JavaScript rendering. Use when asked to scrape, crawl, or extract data from websites; web_fetch fails; the site has anti-bot protections; write Python code to scrape/crawl; or write spiders.

관련 스킬