Communitygithub.com

動畫性能修復

審核並修復動畫性能問題,包括佈局抖動、合成器屬性、滾動相關動畫及模糊效果。適用於動畫卡頓、過渡不流暢或審查 CSS/JS 動畫性能時。

動畫性能修復 是什麼?

此技能旨在幫助開發者診斷並修復 UI 動畫中的性能問題,涵蓋佈局抖動、合成器屬性、滾動相關動畫及模糊效果等常見瓶頸。它提供了一套分優先級的規則(從「禁止模式」到「工具邊界」),指導開發者選擇最輕量的渲染機制(優先使用 transform 和 opacity),避免在每一影格中交錯讀寫佈局,並透過批次處理測量與寫入來優化效能。此技能適用於任何使用 CSS、WAAPI、Motion、rAF 或 GSAP 的動畫工作,並支援在 Cursor 或 Claude Code 等 AI 輔助開發環境中透過 `/fixing-motion-performance` 指令觸發。其核心價值在於提供具體、可操作的審查建議(如引用違規行、說明影響與給出修復範例),而非理論探討,最終目標是在不遷移動畫庫的前提下最大化現有技術棧的渲染效率。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/AlperTuncOrtak/crypto-data-pipeline/tree/HEAD/skills/fixing-motion-performance

在你喜歡的 AI 中提問

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

說明文件

修復動畫性能

修復動畫效能問題。

如何使用

  • /fixing-motion-performance 將這些限制套用至此對話中的所有 UI 動畫工作。

  • /fixing-motion-performance <檔案> 根據以下所有規則審查該檔案,並回報:

    • 違規(引用確切的程式碼行或片段)
    • 為何重要(一句簡短說明)
    • 具體修復方法(程式碼層級的建議)

除非明確要求,否則請勿遷移動畫函式庫。在現有技術棧中套用規則。

使用時機

在以下情況參考這些指南:

  • 新增或修改 UI 動畫(CSS、WAAPI、Motion、rAF、GSAP)
  • 重構卡頓的互動或過渡效果
  • 實作滾動相關動畫或滾動顯示效果
  • 對佈局、濾鏡、遮罩、漸層或 CSS 變數進行動畫
  • 審查使用了 will-change、transform 或尺寸測量的元件

渲染步驟詞彙表

  • composite(合成):transform、opacity
  • paint(繪製):顏色、邊框、漸層、遮罩、圖片、濾鏡
  • layout(佈局):大小、位置、流動、Grid、Flex

按優先級區分的規則類別

優先級類別影響程度
1禁止模式嚴重
2選擇機制嚴重
3測量高
4滾動高
5繪製中高
6圖層中
7模糊與濾鏡中
8視圖轉場低
9工具邊界嚴重

快速參考

1. 禁止模式(嚴重)

  • 請勿在同一影格中交錯執行佈局讀取與寫入
  • 請勿在大型或重要的表面元素上連續對佈局進行動畫
  • 請勿透過 scrollTop、scrollY 或 scroll 事件驅動動畫
  • requestAnimationFrame 迴圈不可缺少停止條件
  • 請勿混合使用多個各自會測量或修改佈局的動畫系統

2. 選擇機制(嚴重)

  • 預設使用 transform 和 opacity 進行動畫
  • 僅在互動需要時才使用 JS 驅動的動畫
  • 僅可在小型、獨立的表面元素上接受 paint 或 layout 動畫
  • 一次性效果比連續運動更容易被接受
  • 優先考慮降級技術而非完全移除動畫

3. 測量(高)

  • 測量一次,然後透過 transform 或 opacity 進行動畫
  • 將所有 DOM 讀取批次處理在寫入之前
  • 不要在動畫過程中反覆讀取佈局
  • 對於類似佈局的效果,偏好使用 FLIP 風格的轉場
  • 偏好能夠批次處理測量和寫入的方法

4. 滾動(高)

  • 當可用時,優先使用 Scroll 或 View Timelines 來處理滾動相關動畫
  • 使用 IntersectionObserver 來判斷可見性與暫停
  • 請勿為了動畫而輪詢滾動位置
  • 在畫面外時暫停或停止動畫
  • 滾動相關動畫不得在大型表面元素上觸發連續的 layout 或 paint

5. 繪製(中高)

  • 觸發 paint 的動畫僅允許在小型、獨立的元素上
  • 請勿在大型容器上對 paint 密集的屬性進行動畫
  • 請勿對 CSS 變數(transform、opacity 或 position)進行動畫
  • 請勿對繼承的 CSS 變數進行動畫
  • 將動畫用的 CSS 變數限定在區域範圍內,避免使用繼承

6. 圖層(中)

  • 合成器動畫需要圖層提升,請勿假設會自動發生
  • 暫時且精準地使用 will-change
  • 避免使用過多或過大的提升圖層
  • 當效能至關重要時,使用工具驗證圖層行為

7. 模糊與濾鏡(中)

  • 保持模糊動畫的數值小(<=8px)
  • 僅對短暫、一次性效果使用模糊
  • 絕不連續對模糊進行動畫
  • 絕不在大型表面元素上對模糊進行動畫
  • 在模糊之前,優先考慮使用 opacity 和 translate

8. 視圖轉場(低)

  • 僅在導航層級的變更時使用視圖轉場
  • 避免在高互動性的 UI 中使用視圖轉場
  • 當需要中斷或取消時,避免使用視圖轉場
  • 將尺寸變更視為可能觸發佈局的變更

9. 工具邊界(嚴重)

  • 除非明確要求,否則請勿遷移或重寫動畫函式庫
  • 在現有動畫系統中套用這些規則
  • 切勿在同一元件中部分遷移 API 或混合不同風格

常見修復範例

/* 佈局抖動:改用 transform 動畫取代 width */
/* 修正前 */ .panel { transition: width 0.3s; }
/* 修正後 */  .panel { transition: transform 0.3s; }

/* 滾動相關動畫:使用 scroll-timeline 取代 JS */
/* 修正前 */ window.addEventListener('scroll', () => el.style.opacity = scrollY / 500)
/* 修正後 */  .reveal { animation: fade-in linear; animation-timeline: view(); }
// 測量:將讀取批次處理在寫入之前(FLIP)
// 修正前 — 佈局抖動
el.style.left = el.getBoundingClientRect().left + 10 + 'px';
// 修正後 — 測量一次,透過 transform 動畫
const first = el.getBoundingClientRect();
el.classList.add('moved');
const last = el.getBoundingClientRect();
el.style.transform = `translateX(${first.left - last.left}px)`;
requestAnimationFrame(() => { el.style.transition = 'transform 0.3s'; el.style.transform = ''; });

審查指引

  • 優先執行嚴重規則(禁止模式、工具邊界)
  • 選擇最符合意圖但渲染成本最低的處理方式
  • 對於任何非預設的選擇,說明其限制條件(表面大小、持續時間或互動需求)
  • 審查時,偏好提供可操作的備註和具體的替代方案,而非理論說明

限制

  • 僅在任務明確符合上述範圍時使用此技能。
  • 請勿將輸出視為環境特定驗證、測試或專家審查的替代品。
  • 若缺少必要的輸入、權限、安全邊界或成功標準,請停止並要求澄清。

Individual skills in this repo

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

AlperTuncOrtak/crypto-data-pipeline

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

AlperTuncOrtak/crypto-data-pipeline

Advanced JavaScript animation library skill for creating complex, high-performance web animations.

AlperTuncOrtak/crypto-data-pipeline

One sentence - what this skill does and when to invoke it

AlperTuncOrtak/crypto-data-pipeline

Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

AlperTuncOrtak/crypto-data-pipeline

Pull a YouTube video transcript into a queryable markdown vault with yt-dlp subtitle discovery, VTT cleanup, metadata frontmatter, and capture-seed stubs.

AlperTuncOrtak/crypto-data-pipeline

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities.

AlperTuncOrtak/crypto-data-pipeline

Generates high-converting Next.js/React landing pages with Tailwind CSS. Uses PAS, AIDA, and BAB frameworks for optimized copy/components (Heroes, Features, Pricing). Focuses on Core Web Vitals/SEO.

AlperTuncOrtak/crypto-data-pipeline

AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

AlperTuncOrtak/crypto-data-pipeline

CRITICAL: Use for Makepad animation system. Triggers on: makepad animation, makepad animator, makepad hover, makepad state, makepad transition, "from: { all: Forward", makepad pressed, makepad 动画, makepad 状态, makepad 过渡, makepad 悬停效果

AlperTuncOrtak/crypto-data-pipeline

Best practices for Remotion - Video creation in React

AlperTuncOrtak/crypto-data-pipeline

Generate walkthrough videos from Stitch projects using Remotion with smooth transitions, zooming, and text overlays

AlperTuncOrtak/crypto-data-pipeline

Seek and analyze video content using Memories.ai Large Visual Memory Model for persistent video intelligence

AlperTuncOrtak/crypto-data-pipeline

Writes complete, structured landing pages optimized for SEO ranking, AEO citation, and visitor conversion. Activate when the user wants to write or generate a landing page for a product, service, or offer.

AlperTuncOrtak/crypto-data-pipeline

Three.js animation - keyframe animation, skeletal animation, morph targets, animation mixing. Use when animating objects, playing GLTF animations, creating procedural motion, or blending animations.

AlperTuncOrtak/crypto-data-pipeline

Automate TikTok tasks via Rube MCP (Composio): upload/publish videos, post photos, manage content, and view user profiles/stats. Always search tools first for current schemas.

AlperTuncOrtak/crypto-data-pipeline

Video and audio perception, indexing, and editing. Ingest files/URLs/live streams, build visual/spoken indexes, search with timestamps, edit timelines, add overlays/subtitles, generate media, and create real-time alerts.

AlperTuncOrtak/crypto-data-pipeline

Upload, stream, search, edit, transcribe, and generate AI video and audio using the VideoDB SDK.

AlperTuncOrtak/crypto-data-pipeline

One sentence - what this skill does and when to invoke it

AlperTuncOrtak/crypto-data-pipeline

Automate YouTube tasks via Rube MCP (Composio): upload videos, manage playlists, search content, get analytics, and handle comments. Always search tools first for current schemas.

AlperTuncOrtak/crypto-data-pipeline

Extract transcripts from YouTube videos and generate comprehensive, detailed summaries using intelligent analysis frameworks

相關技能