Communitygithub.com

astudio · Lottie 與 Rive

整合、控制並最佳化設計師製作的動畫於產品中:支援 dotLottie/Lottie 播放、區段控制、滾動驅動與互動式 Lottie、執行時主題切換、尺寸最佳化;以及 Rive 狀態機(輸入、轉換、監聽器)、ViewModel 資料綁定、事件處理,並涵蓋 Web、React、React Native、iOS、Android、Flutter 等執行環境。

astudio · Lottie 與 Rive 是什麼?

此技能是 astudio 團隊針對 Lottie 與 Rive 動畫的技術整合指南。它能幫助開發者與設計師選擇合適的動畫格式(Lottie 適合設計師製作的線性動畫,如圖示或插畫;Rive 則適用於需要互動與狀態變化的進階動畫,如按鈕狀態或遊戲 UI),並提供從檔案產出、執行時控制到效能最佳化的完整流程。支援的平台包括 Web(dotLottie-web、lottie-interactivity)、React(dotLottie-react、@rive-app/react-canvas)以及原生端 iOS、Android、Flutter。技能還涵蓋 Lottie 的區段式「狀態機」、滾動驅動動畫、執行時主題變換,以及 Rive 的輸入/觸發器控制與 ViewModel 資料綁定。此外,它提供設計師與開發者之間的交接備註,說明如何在 After Effects、Figma Motion、Lottie Creator 與 Cavalry 中準備檔案,並透過腳本進行視覺驗證與尺寸檢查。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/whoamnesia/motion-3d/tree/HEAD/skills/lottie-rive

在你喜歡的 AI 中提問

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

說明文件

astudio · Lottie 與 Rive 是做什麼的?

角色:astudio.one 資深動態設計師與創意開發者(15 年以上經驗)—— 設計師製作的動畫,小巧、清晰且具互動性。基準目錄:<root>/reference/studio-bar.md;<root> 位於此技能基礎目錄上方兩層,或存放 scripts/motion.cjs 的資料夾。

選擇格式

需求選擇
設計師製作的線性動畫(圖示、插畫、引導頁、空狀態),可播放/暫停/分段Lottie(透過 dotLottie 執行環境使用 .lottie)
互動式、具狀態的動畫,能對輸入或應用程式資料做出反應(按鈕含狀態、角色、進度、遊戲 UI、資料驅動插畫)Rive(狀態機 + 資料綁定)
簡單的 UI 狀態變更、懸停/按下、轉場CSS / Motion(astudio-motion:ui-motion)—— 不需要動畫檔案
可用 SVG 繪製並以程式碼動畫化的標誌/圖示SVG + GSAP(astudio-motion:svg-motion)—— 僅在應用程式執行環境需要時才匯出 Lottie
影片類內容(人物、實拍片段)影片(<video>),不要用 Lottie

Lottie 工作流程(references/lottie.md)

  1. 優先使用 .lottie(zip 壓縮,體積小 60-80%,可內嵌圖片、主題、狀態機)搭配 @lottiefiles/dotlottie-web(Canvas + WASM)或 @lottiefiles/dotlottie-react;僅在需要舊版 SVG 渲染器時使用 lottie-web。
  2. 控制:play/pause/stop/setSpeed/setMode/setFrame/setSegment,事件 load/complete/frame;基於區段的「狀態機」(播放 checked 區段,然後循環 idle)。
  3. 滾動:將滾動進度對應到 setFrame;透過 @lottiefiles/lottie-interactivity 無須手動接線即可實現互動。
  4. 執行時主題(品牌色、深色模式)透過 dotLottie 主題/插槽達成——不需要傳送兩個檔案。
  5. 最佳化:移除隱藏圖層/未使用素材,除非必要否則不使用點陣圖,減少遮罩/疊加混合模式/特效(不支援或效能慢),裁剪到可見影格範圍,檢查檔案大小(圖示需小於 50-100KB)。
  6. 無障礙:role="img" + aria-label;在減少動畫模式下暫停(透過 setFrame 顯示有意義的靜止影格);無自動循環 > 5 秒(除非有暫停控制)。

Rive 工作流程(references/rive.md)

  1. 在編輯器中:畫板、時間軸、一個狀態機(狀態、帶條件的轉換、輸入:布林值/數值/觸發器、指標事件監聽器)、用於資料綁定的檢視模型(字串/數值/顏色/列舉/觸發器/列表屬性,綁定到場景屬性)、用於應用程式回呼的事件。
  2. 執行環境:@rive-app/react-canvas(useRive、useStateMachineInput、useViewModel、useViewModelInstance*)、純 JS 用 @rive-app/canvas、iOS/Android/Flutter/RN 的原生執行環境;重度場景使用 WebGL2 渲染器。
  3. 用應用程式資料驅動(資料綁定)而不是一堆輸入;監聽 Rive 事件以觸發應用程式反應。
  4. 預載入關鍵檔案;使用 useRive 的佈局(Fit、Alignment)設定 Canvas 大小;離螢幕時暫停。

視覺檢查

node <root>/scripts/motion.cjs strip page.html --duration <s> 會渲染一個包含 Lottie/Rive 檔案的頁面(時鐘模式驅動其 rAF 循環)。檢查第一幀和最後一幀、區段邊界以及主題切換後的顏色。

交接備註(給設計師)

  • AE -> Lottie:使用 Bodymovin/LottieFiles 插件;支援:形狀圖層、變形、修剪路徑、遮罩(有限)、文字(建議轉為外框)、預合成;避免:重度表達式綁定、特效、3D 圖層、混合模式。
  • Figma Motion 可匯出 MP4/GIF/SVG/WebM 以及程式碼(CSS/React/motion.dev)——若需要 Lottie,請使用 Lottie Creator 或 LottieFiles 插件。Cavalry 原生支援匯出 Lottie。
  • 有意義地命名圖層(它們會成為主題切換和除錯的選擇器);交付包含主題的 .lottie 檔案。

Individual skills in this repo

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

whoamnesia/gsap

GSAP motion by astudio: timelines, ScrollTrigger scroll storytelling (pin, scrub, horizontal galleries, parallax), SplitText headline reveals, Flip layout transitions, MorphSVG/DrawSVG/MotionPath, Draggable/Inertia/Observer, CustomEase, quickTo cursor followers, Lenis smooth scroll, page transitions (Barba, View Transitions) and award- style landing-page motion in vanilla JS, React (useGSAP), Next.js, Vue, Nuxt, Svelte and Astro - with cleanup, responsive and reduced-motion handling via gsap.matchMedia. Use for "GSAP", "ScrollTrigger", "scroll animation", "pinned section", "horizontal scroll", "text reveal", "как на Awwwards", "анимация при скролле", "параллакс". All GSAP plugins are free (GSAP 3.13+).

whoamnesia/motion-review

Motion review and audit by astudio: reviews animation code and rendered motion against a strict craft bar, audits a whole codebase's motion, diagnoses jank and performance, finds where motion is missing (opportunities) and removes motion that should not exist - for websites, product UI, GSAP/Motion/CSS, Lottie/Rive, three.js and rendered videos. Use for "review my animations", "why is this janky", "this feels cheap/slow/AI-made", "audit the motion", "where should we add animation", "remove unnecessary animations", "проверь анимации", "почему дёргается", "аудит моушена". Default to flagging; approval is earned. Outputs a findings table and a Block/Approve verdict, with rendered strips as evidence.

whoamnesia/ui-motion

Interface animation by astudio: builds motion for UI components and flows - buttons, dropdowns, popovers, tooltips, modals, drawers, toasts, accordions, tabs, lists, skeletons, route/page transitions, shared-element morphs, drag and gestures - with CSS (@starting-style, scroll-driven animations), WAAPI, View Transitions, Motion (motion.dev / framer-motion) in React, Vue, Svelte or plain HTML; defines motion systems and tokens; implements Figma Motion designs via the Figma MCP (get_motion_context). Use for "animate this component", "add a transition", "make it feel alive/smooth/native", "page transition", "motion tokens", "микроанимации", "анимация интерфейса", "плавные переходы". Decides whether something should animate at all before writing code.

相關技能