Communitygithub.com

Lottie アニメーション

After Effects のアニメーションを JSON または .lottie 形式で Web、iOS、Android、React Native に統合・再生・制御・書き出しするためのスキルです。

Lottie アニメーション とは?

このスキルは、After Effects で制作されたベクターアニメーションを、Lottie 形式(JSON または圧縮された .lottie)でプロダクトに組み込むための包括的なガイドを提供します。Web では @lottiefiles/dotlottie-web や @lottiefiles/dotlottie-react を使用した最新の dotLottie ランタイムを推奨し、レガシーな lottie-web との使い分けも解説します。再生制御(play/pause/stop、セグメント指定、フレームジャンプ)、スクロール駆動アニメーション、ランタイムテーマ変更(setTheme)など、インタラクティブな実装に必要な API を網羅。iOS/Android/React Native の各モバイルランタイムとの API 互換性にも触れています。さらに、単一 HTML ファイルで完結する配布用デモの作り方や、?t=N パラメータによるフレーム固定の検証方法、パフォーマンス最適化のベストプラクティスも提供。スキル全体として、デザイナーが書き出した Lottie を開発者が迷わず実装・検証・出荷できるように設計されています。

対応~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/nehakanjamala/personal_website/tree/HEAD/.agents/skills/lottie-animation

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Lottie アニメーション は何をしますか?

After Effects からプロダクトへの架け橋:JSON(または圧縮された .lottie)として書き出されるベクターアニメーション。軽量で解像度に依存せず、Web、iOS、Android、React Native でランタイムによって再生されます。このスキルでは、Lottie の統合、制御、書き出しについて説明します。

使用するタイミング

  • デザイナーが作成した AE アニメーションを Web/iOS/Android/React Native に出荷する
  • ループするイラスト、オンボーディング、空の状態、アニメーションアイコン
  • スクロールやインタラクション(ホバー、クリック、カーソル)に基づくベクター再生
  • ブランドごとに再書き出しする代わりに、ランタイムでのテーマ変更/色変更

フォーマット: .json vs .lottie

  • .json — Bodymovin の生の出力。人間が読みやすく、ファイルサイズが大きい。
  • .lottie — 圧縮されたコンテナ(通常 60~80% 小型化)で、複数のアニメーション、画像、テーマをバンドル可能。出荷時に推奨。プレイヤー:@lottiefiles/dotlottie-web(モダン、canvas + WASM)は古い lottie-web を置き換えます。

新しい作業には dotLottie ランタイムを推奨。lottie-web はレガシーな .json + SVG レンダラーのニーズがある場合のみ使用します。

コアワークフロー(Web、dotLottie)

npm i @lottiefiles/dotlottie-web        # バニラ
npm i @lottiefiles/dotlottie-react      # React ラッパー

バニラ:

import { DotLottie } from "@lottiefiles/dotlottie-web";

const dotLottie = new DotLottie({
  canvas: document.querySelector("#lottie"),  // <canvas> 要素
  src: "/hero.lottie",                         // または .json
  loop: true,
  autoplay: true,
  // speed: 1, mode: "forward" | "reverse" | "bounce", renderConfig: { autoResize: true }
});

React:

import { DotLottieReact } from "@lottiefiles/dotlottie-react";

function Hero() {
  return <DotLottieReact src="/hero.lottie" loop autoplay style={{ width: 320 }} />;
}

インスタンスを取得して制御する:

const [dl, setDl] = useState(null);
<DotLottieReact src="/icon.lottie" dotLottieRefCallback={setDl} />;
// dl?.play(); dl?.pause(); dl?.setSpeed(2);

再生制御

dotLottie.play();
dotLottie.pause();
dotLottie.stop();
dotLottie.setSpeed(1.5);
dotLottie.setMode("bounce");        // forward | reverse | bounce | reverse-bounce
dotLottie.setFrame(42);             // 特定のフレームにジャンプ
dotLottie.setSegment(30, 90);       // 再生をフレーム範囲に制限(例: "ローディング" ループ)

イベントでシーケンスと UI を駆動:

dotLottie.addEventListener("load", () => { /* totalFrames が利用可能に */ });
dotLottie.addEventListener("complete", () => { /* 非ループ再生が終了 */ });
dotLottie.addEventListener("frame", ({ currentFrame }) => { /* フレームごと */ });

ステートマシンスタイル(例:"checked" セグメントを再生してアイドル状態になるボタン): セグメントを再生し、complete をリッスンしてから setSegment でアイドルループに移行します。

スクロール駆動 Lottie(GSAP は不要)

スクロールの進行度(0~1)をフレームにマッピングします。自動再生を停止し、自分でフレームを制御します。

const dotLottie = new DotLottie({ canvas, src: "/scroll.lottie", autoplay: false });
let total = 0;
dotLottie.addEventListener("load", () => { total = dotLottie.totalFrames; });

window.addEventListener("scroll", () => {
  const el = canvas.closest(".scrolly");
  const rect = el.getBoundingClientRect();
  const p = clamp(-rect.top / (rect.height - window.innerHeight), 0, 1); // セクション内の 0..1
  dotLottie.setFrame(p * (total - 1));
}, { passive: true });

const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));

配線を自分で書かずに、よりリッチなインタラクション(ホバーで再生、クリックで切り替え、カーソル追従)を実現するには、@lottiefiles/lottie-interactivity を使用します。これは scroll、hover、click、play、cursor モードを宣言的にフレーム範囲にマッピングします。

ランタイムテーマ / 色変更

2 つの方法:

  • dotLottie テーマ: .lottie に名前付きカラーテーマを埋め込めます。dotLottie.setTheme("dark") / loadTheme(...) で切り替え。LottieFiles のツールで作成 — 色変更のために再書き出しは不要。
  • 手動での色上書き: JSON を読み込み、layers[].shapes[] を走査して c.k の色配列(正規化された 0~1 RGBA)を修正し、変更したオブジェクトでプレイヤーを初期化。レイヤー構造に依存するため不安定 — クラスベースで再スタイルする必要がある場合は、テーマまたは CSS 駆動の SVG レンダラー(lottie-web rendererSettings)を推奨します。

モバイルランタイム(同等性)

  • iOS — lottie-ios (LottieAnimationView): .play(), .currentProgress, .play(fromFrame:toFrame:).
  • Android — lottie-android (LottieAnimationView / Compose LottieAnimation): setMinAndMaxFrame, progress.
  • React Native — lottie-react-native (<LottieView source={...} progress={anim} />, progress を Animated で駆動).

同じ .lottie/.json が全てのプラットフォームで再生され、セグメントや進行度の概念は Web API と一致します。

最適化

  • 生の .json ではなく .lottie(圧縮済み)を出荷し、オフスクリーンのプレイヤーは遅延読み込みし、表示されていないときは一時停止(IntersectionObserver → play/pause)。
  • 多数のアニメーションを同時に再生する場合は canvas/WASM の dotLottie レンダラーを推奨。SVG レンダラー(lottie-web)は鮮明なアイコン1つには適していますが、複雑なファイルでは DOM コストが高くなります。
  • AE コンポジションは小さく保つ:レイヤー/キーフレームを減らし、大きな埋め込みラスターを避け、可能な限りプリコンポーズを平坦化。ファイルサイズは時間ではなくキーフレームとパスの複雑さに比例します。
  • ブランド/テーマごとにファイルを書き出す代わりに、ランタイムで色変更(テーマ)します。

納品と検証(スタンドアロン 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 を参照。

自己完結型の Lottie デモ(ループするイラスト、アニメーションアイコン、空の状態)の場合、納品物は ブラウザで直接開く 1 つの HTML ファイル — CDN からの dotLottie/lottie-web ランタイム、<canvas>、そして .lottie/.json(相対ファイルまたはデータ URL)。ビルドステップは不要。1 ファイルはプレイヤーを出荷するのに適切なレベルです;バンドラーを使用する必要はありません。

出力契約:

  • 1 つの .html ファイル:CDN 経由のランタイム(@lottiefiles/dotlottie-web)、canvas、そしてフレームを自分で制御できるよう autoplay:false。
  • 任意のフレームをスクリーンショット用にフリーズできるシークハーネスを含める。

シークハーネス — 正確なフレームをフリーズ。 ?t=N でフレームにジャンプして保持し、スクリーンショットが静止した決定論的なフレームに収まるようにします。Lottie の再生ヘッドはフレーム単位なので、フレーム上で直接停止します:

<script>
  const dl = new DotLottie({ canvas, src: "/icon.lottie", autoplay: false });
  dl.addEventListener("load", () => {
    const t = new URLSearchParams(location.search).get("t");
    if (t !== null) dl.setFrame(parseFloat(t));      // フレーム N でフリーズ(lottie-web: anim.goToAndStop(N, true))
    else dl.play();
    console.log("totalFrames", dl.totalFrames);       // 終了フレームを読み取る
    window.__ready = true;
  });
</script>

検証ループ — レンダリング → フリーズ → スクリーンショット → チェック: 最初 / 中間 / 最後のフレーム(?t=0、?t=<total/2>、?t=<total-1>; totalFrames はコンソールから読み取り)でファイルを開き、それぞれをスクリーンショットし、忠実度(色/テーマが正しいか、セグメントループが意図通りか)とアーティファクト(autoResize/DPR の欠落による canvas のぼやけ、コンポジションのクリッピング、ファイル読み込み前の FOUC、カクつき)を確認します。任意のヘッドレスツールで動作します:

npx playwright screenshot --wait-for-timeout=600 "file://$PWD/lottie.html?t=42" frame-mid.png

完了前に確認すること:

  1. スタンドアロンで開く — コンソールエラーなし、CDN ランタイムと .lottie/.json が読み込まれる。
  2. ?t=N(setFrame/goToAndStop)が正しい決定論的なフレームをフリーズする。
  3. 最初 / 中間 / 最後のフレームをスクリーンショット — 要件に一致し、シャープで、クリッピングなし。
  4. prefers-reduced-motion を尊重 — ループを autoplay しない;静的なフレームを表示するか、再生コントロールを提供する。
  5. イージングは意図的 — 再生速度/セグメントは意図的に選択され、AE でベイクされたモーションは設計通りに読まれる。

クイックリファレンス

目的呼び出し
範囲を再生setSegment(start, end)
フレームにジャンプsetFrame(n)
逆再生 / バウンス`setMode("reverse"
スクロール駆動autoplay:false + setFrame(p*totalFrames)
テーマ切り替えsetTheme("dark")
長さを知るload イベント後の totalFrames
宣言的インタラクティビティ@lottiefiles/lottie-interactivity

参考ファイル

  • references/integration-and-export.md — 完全な dotLottie-web + React のセットアップとイベント/セグメント制御、lottie-interactivity のモード設定、スクロール/カーソルパターン、ランタイムテーマの詳細、そして After Effects → Bodymovin 書き出しチェックリスト(サポートされていない AE 機能とその回避方法のリストを含む)。

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 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.

nehakanjamala/personal_website

This skill should be used when the user asks to "animate an SVG", "make a line draw itself on", "do a stroke draw-on / signature animation", "morph one shape into another", "move an element along a path", "animate an icon/logo", or "animate an SVG gradient or filter". Covers stroke-dashoffset draw-on, path morphing, motion-along-path, and animated icons/gradients/filters via CSS, SMIL, and GSAP.

関連スキル