Communitygithub.com

運動性能修復 (Animation Performance Fix)

審計並修復動畫效能問題,包括佈局抖動、合成器屬性、滾動關聯動畫和模糊效果。當動畫卡頓、轉場不順或檢視 CSS/JS 動畫效能時使用。

運動性能修復 (Animation Performance Fix) 是什麼?

此技能專注於診斷和修復 Web 動畫中的效能問題,涵蓋 CSS 動畫、WAAPI、JavaScript 驅動動畫(如 rAF、GSAP)及滾動關聯效果。它根據渲染步驟(合成、繪製、佈局)的效能影響進行分類,並提供明確的規則類別(如「永不模式」、「選擇機制」、「測量」、「滾動」等),每個類別都有優先級和影響級別。技能支援多個 AI 代理平台,包括 Claude Code、Cursor、Codex 等,並提供常見修復範例(如佈局抖動、滾動關聯動畫)的程式碼片段。它能幫助開發者避免常見的效能陷阱,如交錯讀寫佈局、動畫繪製密集型屬性或持續使用模糊效果,並選擇最輕量的渲染工作來匹配動畫意圖。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/AbobakrDiara61/railway-system/tree/HEAD/frontend/skills/fixing-motion-performance

在你喜歡的 AI 中提問

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

說明文件

修復運動效能

修復動畫效能問題。

如何使用

  • /fixing-motion-performance 將這些限制套用到此對話中任何 UI 動畫工作。

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

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

除非明確要求,否則請勿遷移動畫庫。在現有技術堆疊內套用規則。

使用時機

在以下情況參考這些準則:

  • 新增或更改 UI 動畫(CSS、WAAPI、Motion、rAF、GSAP)
  • 重構卡頓的互動或轉場
  • 實作滾動關聯動畫或捲動顯示效果
  • 動畫化佈局、濾鏡、遮罩、漸層或 CSS 變數
  • 檢視使用 will-change、transform 或測量的元件

渲染步驟詞彙表

  • 合成:transform、opacity
  • 繪製:顏色、邊框、漸層、遮罩、圖片、濾鏡
  • 佈局:大小、位置、流動、網格、彈性

規則類別(依優先級)

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

快速參考

1. 永不模式(嚴重)

  • 請勿在同一影格中交錯進行佈局讀取和寫入
  • 請勿在大型或重要表面上持續動畫化佈局
  • 請勿使用 scrollTop、scrollY 或 scroll 事件驅動動畫
  • 沒有停止條件的 requestAnimationFrame 迴圈不可使用
  • 請勿混用多個各自測量或變更佈局的動畫系統

2. 選擇機制(嚴重)

  • 預設使用 transform 和 opacity 進行運動
  • 僅在互動需要時使用 JS 驅動動畫
  • 僅在小型、隔離的表面上允許繪製或佈局動畫
  • 一次性效果比持續運動更容易被接受
  • 優先降級技術而非完全移除運動

3. 測量(高)

  • 只測量一次,然後透過 transform 或 opacity 進行動畫
  • 在寫入之前批次處理所有 DOM 讀取
  • 不要在動畫期間重複讀取佈局
  • 優先使用 FLIP 風格的轉場來實現類似佈局的效果
  • 優先採用批次處理測量和寫入的方法

4. 滾動(高)

  • 滾動關聯動畫優先使用 Scroll 或 View 時間軸(若可用)
  • 使用 IntersectionObserver 進行可見性檢測和暫停
  • 請勿輪詢滾動位置來驅動動畫
  • 當元件離開螢幕時暫停或停止動畫
  • 滾動關聯動畫不得在大型表面上觸發持續佈局或繪製

5. 繪製(中高)

  • 僅在小型、隔離的元素上允許觸發繪製的動畫
  • 請勿在大型容器上動畫化繪製密集的屬性
  • 請勿動畫化 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.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

Astropy is the core Python package for astronomy, providing essential functionality for astronomical research and data analysis.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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 悬停效果

AbobakrDiara61/railway-system

Best practices for Remotion - Video creation in React

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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

AbobakrDiara61/railway-system

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.

AbobakrDiara61/railway-system

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

相關技能