Communitygithub.com

whoamnesia/lottie-rive

集成、控制和优化设计师制作的动画(Lottie 和 Rive),支持播放、分段、滚动驱动、交互、运行时主题和尺寸优化。

lottie-rive 是什么?

该技能提供了一套完整的 Lottie 和 Rive 动画工作流指南,帮助开发者在产品中高效集成设计师创作的高质量动画。它涵盖了 Lottie (含 .lottie 格式) 的播放控制、分段状态机、滚动驱动交互、运行时主题切换以及尺寸优化;同时详细介绍了 Rive 的状态机、数据绑定、事件处理和跨平台运行时(Web, React, React Native, iOS, Android, Flutter)。技能还提供了格式选择建议(Lottie vs Rive vs 纯 CSS/SVG 动画),并包含了从 After Effects/Bodymovin、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 绘制并通过代码动画的 logo/图标SVG + GSAP(astudio-motion:svg-motion)—— 仅当应用运行时需要时才导出 Lottie
视频类内容(人物、素材)视频(<video>),不推荐 Lottie

Lottie 工作流(references/lottie.md)

  1. 优先使用 .lottie(压缩包,体积减小 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*),@rive-app/canvas 用于原生,iOS/Android/Flutter/RN 的本地运行时;复杂场景使用 WebGL2 渲染器。
  3. 通过应用数据(数据绑定)驱动动画,而非大量输入;监听 Rive 事件以触发应用响应。
  4. 预加载关键文件;使用 useRive 的布局(Fit、Alignment)设置画板尺寸;离屏时暂停。

查看

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.

相关技能