Communitygithub.com

nehakanjamala/personal_website

此技能應在用戶要求「加入 Lottie 動畫」、「播放 .lottie 或 .json 動畫」、「在網頁或行動端整合 Bodymovin/After Effects 動畫」、「控制 Lottie 播放/片段」、「製作滾動驅動的 Lottie」、「在執行時期重新著色 Lottie」或「將 AE 動畫匯出為 Lottie」時使用。涵蓋 dotLottie/lottie-web 整合、播放控制、互動性、主題設定以及 AE 匯出檢查清單。

personal_website 是什麼?

此技能提供從 After Effects 到產品的完整 Lottie 動畫橋接:將向量動畫以 JSON(或壓縮的 .lottie)格式匯出,檔案小且解析度無關,並透過執行時期在網頁、iOS、Android 及 React Native 上播放。它涵蓋了整合、控制與匯出 Lottie 動畫的完整流程,特別推薦使用現代化的 dotLottie 執行時期(含 Canvas + WASM)取代舊有的 lottie-web。技能詳細說明了 .json 與 .lottie 格式的差異、核心工作流程(包括 Vanilla JS 與 React 的整合方式)、播放控制(如 play/pause/setFrame/setSegment)、事件驅動的動畫序列、無需 GSAP 的滾動驅動 Lottie 實作、執行時期主題與重新著色技術、行動端(iOS/Android/React Native)的 API 對應、最佳化建議,以及提供一個可獨立運作的 HTML 交付範本,並包含 `?t=N` 搜尋控制器以精確凍結影格供截圖驗證。

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

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Lottie 動畫

從 After Effects 到產品的橋樑:以 JSON(或壓縮的 .lottie)格式匯出的向量動畫,檔案小巧且解析度無關,由執行時期在網頁、iOS、Android 和 React Native 上播放。此技能涵蓋了整合、控制以及匯出 Lottie 相關內容。

使用時機

  • 將設計師的 AE 動畫部署到網頁/iOS/Android/React Native
  • 循環展示的插圖、引導頁、空白狀態、動態圖示
  • 滾動驅動或互動驅動的向量播放(懸停、點擊、游標跟隨)
  • 執行時期的主題設定/重新著色,而非為每個品牌重新匯出

格式:.json vs .lottie

  • .json — Bodymovin 的原始輸出。人類可讀,檔案較大。
  • .lottie — 壓縮的容器(通常體積減少 60–80%),可包含多個動畫、圖片和主題。建議用於部署。播放器:@lottiefiles/dotlottie-web(現代化,Canvas + WASM)已取代舊版的 lottie-web。

新的專案請優先使用 dotLottie 執行時期;僅在需要舊版 .json + SVG 渲染器時才使用 lottie-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 }) => { /* 每個影格觸發 */ });

狀態機風格(例如:一個按鈕播放「已勾選」片段,然後閒置):播放一個片段,監聽 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 模式宣告式地對應到影格範圍。

執行時期主題設定 / 重新著色

兩種方式:

  • 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} />,使用 Animated 驅動 progress)。

相同的 .lottie/.json 可在所有平台上播放;片段與進度概念與 Web API 一致。

最佳化

  • 使用 .lottie(壓縮)而非原始 .json;延遲載入螢幕外播放器,並在不可見時暫停(IntersectionObserver → play/pause)。
  • 若同時有多個動畫,優先使用 Canvas/WASM dotLottie 渲染器;SVG 渲染器(lottie-web)適合單一清晰的圖示,但處理複雜檔案時會耗費更多 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 示範(循環插圖、動態圖示、空白狀態),交付物是一個可直接在瀏覽器中開啟的 HTML 檔案 — 其中包含來自 CDN 的 dotLottie/lottie-web 執行時期、一個 <canvas>,以及你的 .lottie/.json(相對檔案或 data URL)。無需建置步驟。一個檔案是交付播放器的正確層級;不需要動用到打包工具。

輸出約定:

  • 一個 .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),對每個影格截圖,並檢查忠實度(顏色/主題正確,片段循環如預期)以及瑕疵(canvas 因缺少 autoResize/DPR 而模糊、合成內容被裁剪、檔案載入前的 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 — 不要自動播放循環;顯示靜止影格或提供播放控制。
  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.

相關技能