Communitygithub.com

David-Li0406/meta-skill-evloving

使用 Motion 函式庫實現動畫效果。適用於在元件中加入動作、轉場、手勢、滾動效果或互動式動畫。由實作請求觸發,而非概念性討論。

meta-skill-evloving 是什麼?

此技能專注於使用 Motion 函式庫(https://motion.dev)在 React 專案中實現高效能動畫。它提供從快速入門到進階模式(如彈簧物理、手勢互動、佈局動畫、滾動連結效果、子元素錯開與進出場動畫)的完整指引。Motion 函式庫支援 GPU 加速的變形(transform)與透明度(opacity)動畫,並內建可及性支援,能自動尊重使用者的「減少動畫」偏好設定。技能文件也包含效能最佳化建議、動畫設計原則(如時機掌握與使用時機)以及常見模式(如載入狀態、通知提示、抽屜與手風琴選單)的實作範例,並提供官方文件與範例資源連結。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/David-Li0406/meta-skill-evloving/tree/HEAD/skill-flow/data/skills-refined-36k/skillsmp/animation

在你喜歡的 AI 中提問

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

說明文件

使用 Motion 實作動畫

使用 Motion 函式庫(https://motion.dev)處理所有動畫工作。

快速入門

React(主要):

import { motion } from "motion/react"

// 基本動畫
<motion.div animate={{ opacity: 1, y: 0 }} />

// 含轉場設定
<motion.div
  animate={{ x: 100 }}
  transition={{ type: "spring", stiffness: 100 }}
/>

核心模式

1. 彈簧物理(建議使用)

<motion.div
  animate={{ scale: 1 }}
  transition={{
    type: 'spring',
    stiffness: 260,
    damping: 20,
  }}
/>

彈簧預設值:

  • 柔和:stiffness: 120, damping: 14
  • 彈性:stiffness: 180, damping: 12
  • 僵硬:stiffness: 300, damping: 20

2. 手勢互動

<motion.div
  whileHover={{ scale: 1.05 }}
  whileTap={{ scale: 0.95 }}
  drag="x"
  dragConstraints={{ left: -100, right: 100 }}
/>

3. 佈局動畫

<motion.div layout>{/* 會改變位置/大小的內容 */}</motion.div>

4. 滾動連結效果

import { useScroll, useTransform } from "motion/react"

const { scrollYProgress } = useScroll()
const opacity = useTransform(scrollYProgress, [0, 1], [1, 0])

<motion.div style={{ opacity }} />

5. 子元素錯開

<motion.ul
  variants={{
    visible: { transition: { staggerChildren: 0.07 } },
  }}
>
  {items.map((item) => (
    <motion.li
      key={item}
      variants={{
        hidden: { opacity: 0, y: 20 },
        visible: { opacity: 1, y: 0 },
      }}
    />
  ))}
</motion.ul>

6. 進場/出場動畫

import { AnimatePresence } from 'motion/react';

<AnimatePresence>
  {show && <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} />}
</AnimatePresence>;

動畫屬性

變形(GPU 加速,效能佳):

  • x, y, z - 平移
  • scale, scaleX, scaleY - 縮放
  • rotate, rotateX, rotateY, rotateZ - 旋轉
  • skew, skewX, skewY - 傾斜

視覺屬性(謹慎使用,可能影響效能):

  • opacity
  • background, backgroundColor
  • color
  • borderRadius

SVG 專用:

  • pathLength - 路徑繪製動畫
  • pathOffset - 路徑偏移
  • pathSpacing - 虛線間距

可及性

一律尊重使用者偏好:

<motion.div
  animate={{ x: 100 }}
  transition={{
    type: 'spring',
    // 若使用者偏好減少動畫,則停用動畫
    duration: 0,
  }}
/>

Motion 會自動處理 prefers-reduced-motion。彈簧動畫會變為即時轉場。

效能提示

  1. 盡可能只動畫變形/透明度(GPU 加速)
  2. 使用 layout 屬性,避免手動動畫寬度/高度
  3. 盡量避免在滾動時執行動畫
  4. 對複雜動畫使用 will-change: transform(Motion 會自動處理)
  5. 限制同時動畫的數量 - 使用錯開而非一次全部執行

設計原則(簡要)

何時動畫

  • 狀態轉換(載入 → 成功)
  • 空間變化(進入/離開視野)
  • 吸引注意力(謹慎使用)
  • 確認使用者動作

何時不該動畫

  • 重複動作(首次發生後)
  • 效能關鍵路徑
  • 使用者控制的滾動
  • 每一次互動(克制很重要)

時間指南

  • 微互動:150-250 毫秒
  • 面板/模態轉場:200-300 毫秒
  • 頁面轉場:300-500 毫秒
  • 彈簧:讓物理決定持續時間

彈簧 vs 持續時間

  • 彈簧適用於:互動元素、手勢、佈局變化
  • 持續時間適用於:有意義的序列、編排、載入動畫

請參閱 principles.md 以取得詳細的動畫哲學。

常見模式

載入狀態:

<motion.div
  animate={{ rotate: 360 }}
  transition={{
    repeat: Infinity,
    duration: 1,
    ease: 'linear',
  }}
/>

通知提示:

<motion.div
  initial={{ x: 400, opacity: 0 }}
  animate={{ x: 0, opacity: 1 }}
  exit={{ x: 400, opacity: 0 }}
  transition={{ type: 'spring', stiffness: 300, damping: 30 }}
/>

抽屜:

<motion.div
  initial={{ x: '-100%' }}
  animate={{ x: 0 }}
  exit={{ x: '-100%' }}
  transition={{ type: 'spring', damping: 25 }}
/>

手風琴:

<motion.div
  animate={{ height: isOpen ? 'auto' : 0 }}
  transition={{ type: 'spring', bounce: 0 }}
  style={{ overflow: 'hidden' }}
/>

資源

快速排除問題

動畫沒有執行?

  • 檢查元素是否為條件式渲染(使用 AnimatePresence)
  • 確認目標值與初始值不同
  • 檢查是否有 CSS 覆蓋(例如 !important)

效能問題?

  • 只使用變形和透明度
  • 使用 layout 屬性代替動畫尺寸
  • 檢查瀏覽器 DevTools 的「效能」分頁

佈局動畫閃爍?

  • 確保父層設有 position: relative
  • 必要時在父層和子層都加上 layout
  • 檢查是否有衝突的 CSS 轉場

備註

  • Motion 採用 MIT 授權,已可投入生產環境
  • 混合引擎:120fps,GPU 加速
  • 內建 TypeScript 支援
  • 可樹狀搖晃以達到最佳套件大小
  • 支援 React 18+(包含 Suspense)

Individual skills in this repo

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

David-Li0406/meta-skill-evloving

Browser automation with persistent page state. Use when users ask to navigate websites, fill forms, take screenshots, extract web data, test web apps, or automate browser workflows. Trigger phrases include "go to [url]", "click on", "fill out the form", "take a screenshot", "scrape", "automate", "test the website", "log into", or any browser interaction request.

David-Li0406/meta-skill-evloving

Create technical diagrams using Mermaid syntax for architecture, sequences, ERDs, flowcharts, and state machines. Use for visualizing system design, data flows, and processes. Triggers: diagram, mermaid, architecture diagram, sequence diagram, flowchart, ERD, entity relationship, state diagram, C4 model, component diagram, visualize, draw.

David-Li0406/meta-skill-evloving

Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks

David-Li0406/meta-skill-evloving

Complete color manipulation and green screen effects system. PROACTIVELY activate for: (1) Green screen/chromakey removal, (2) Color grading with LUTs, (3) Color correction (levels, curves, white balance), (4) Colorkey/color removal effects, (5) Hue/saturation manipulation, (6) Color space conversions (BT.709, BT.2020, HDR), (7) Color isolation effects, (8) Teal and orange look, (9) Vintage/film looks, (10) Color keying for transparency. Provides: chromakey and colorkey filters, LUT application (lut3d), curves and levels adjustment, color balance, selective color manipulation, color space handling, HDR tone mapping, professional color grading chains.

David-Li0406/meta-skill-evloving

Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.

David-Li0406/meta-skill-evloving

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

David-Li0406/meta-skill-evloving

Build with OpenAI's stateless APIs - Chat Completions (GPT-5, GPT-4o), Embeddings, Images (DALL-E 3), Audio (Whisper + TTS), and Moderation. Includes Node.js SDK and fetch-based approaches for Cloudflare Workers. Use when: implementing chat completions with GPT-5/GPT-4o, streaming responses with SSE, using function calling/tools, creating structured outputs with JSON schemas, generating embeddings for RAG (text-embedding-3-small/large), generating images with DALL-E 3, editing images with GPT-Image-1, transcribing audio with Whisper, synthesizing speech with TTS (11 voices), moderating content (11 safety categories), or troubleshooting rate limits (429), invalid API keys (401), function calling failures, streaming parse errors, embeddings dimension mismatches, or token limit exceeded.

David-Li0406/meta-skill-evloving

Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.

David-Li0406/meta-skill-evloving

Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks

David-Li0406/meta-skill-evloving

Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas

David-Li0406/meta-skill-evloving

Download YouTube videos with customizable quality and format options. Use this skill when the user asks to download, save, or grab YouTube videos. Supports various quality settings (best, 1080p, 720p, 480p, 360p), multiple formats (mp4, webm, mkv), and audio-only downloads as MP3.

David-Li0406/meta-skill-evloving

Best practices for Remotion - Video creation in React

David-Li0406/meta-skill-evloving

Provides bidirectional translation (Chinese/English), grammar checking, and sentence polishing. Supports specific tense constraints, context-aware tone adjustment, and natural expression optimization. Outputs direct text without formatting.

David-Li0406/meta-skill-evloving

指导如何通过自定义注解(如@Unicom)标识Dubbo接口,利用BeanDefinitionRegistryPostProcessor在启动时扫描并动态注册ReferenceBean,实现RPC调用的封装。

David-Li0406/meta-skill-evloving

生成Python脚本,利用FFmpeg将图片序列按3x3布局合并,或将合并图拆分。要求使用subprocess模块执行命令,并支持用户交互式输入路径。

David-Li0406/meta-skill-evloving

SOP for extracting and analyzing promotional activity details, handling time formatting, location mapping, payment logic, and step-by-step process validation.

David-Li0406/meta-skill-evloving

Specializes in creating TikTok short video scripts using an anthropomorphic 'Chef' perspective to explain wildlife food chains and survival environments, utilizing real field footage.

David-Li0406/meta-skill-evloving

针对TikTok平台,以拟人化视角(如动物作为厨师)创作系列短视频脚本。重点介绍野生动物、食物链及生态环境,要求使用野外实拍素材,风格幽默且具有教育意义。

David-Li0406/meta-skill-evloving

Generates KWL (Know, Want to know, Learned) charts for educational videos, specifically BrainPOP, using simple 7th-grade language and short, concise bullet points.

David-Li0406/meta-skill-evloving

Tracks complex, multi-session work using the Beads issue tracker and dependency graphs, and provides persistent memory that survives conversation compaction. Use when work spans multiple sessions, has complex dependencies, or needs persistent context across compaction cycles. Trigger with phrases like "create task for", "what's ready to work on", "show task", "track this work", "what's blocking", or "update status".

相關技能