Communitygithub.com

BEKO2210/Firstbrain

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

Firstbrain 是什麼?

這個技能提供了一套全面的靜態規則,用於審計和修復 UI 動畫中的效能瓶頸。它涵蓋了從關鍵的「永不使用模式」(如佈局抖動和無止境的 requestAnimationFrame 迴圈)到較低優先級但仍有影響的領域(如視圖過渡和模糊效果)。其主要價值在於提供了一個結構化的審計框架,按照渲染影響(複合、繪製、佈局)和優先級對規則進行分類。支援的平台包括任何使用 CSS、JavaScript (WAAPI、rAF、GSAP) 或視圖過渡機制的標準網頁開發環境。此技能會針對特定檔案生成詳細報告,引用違規的程式碼行,解釋其影響,並提供具體的修正建議,同時嚴格要求不重寫整個動畫函式庫,除非明確要求。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/BEKO2210/Firstbrain/tree/HEAD/03%20-%20Resources/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):尺寸、位置、流向、網格、彈性盒

規則類別與優先級

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

快速參考

1. 永不使用模式(嚴重)

  • 不要在同一幀中交錯執行佈局讀取和寫入
  • 不要在大面積或有重要意義的表面上連續對佈局進行動畫
  • 不要透過 scrollTop、scrollY 或 scroll 事件驅動動畫
  • 禁止使用沒有停止條件的 requestAnimationFrame 迴圈
  • 不要混合使用多個各自測量或變異佈局的動畫系統

2. 選擇動畫機制(嚴重)

  • 預設使用 transform 和 opacity 來製作動畫
  • 僅在互動需要時才使用 JavaScript 驅動的動畫
  • 僅在小而孤立的表面上才可接受對繪製或佈局進行動畫
  • 一次性效果比連續動畫更常可被接受
  • 優先選擇降級技術而非完全移除動畫

3. 尺寸測量(高)

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

4. 滾動(高)

  • 對於滾動相關的動畫,若有 Scroll 或 View Timelines 可用,請優先使用
  • 使用 IntersectionObserver 來偵測可見性並暫停動畫
  • 不要輪詢滾動位置來驅動動畫
  • 當元件離開畫面時,暫停或停止動畫
  • 滾動相關動畫不得在大面積表面上觸發連續的佈局或繪製

5. 繪製(中高)

  • 僅允許在小而孤立的元素上對會觸發繪製的屬性進行動畫
  • 不要在大型容器上對繪製成本高的屬性進行動畫
  • 不要對用於 transform、opacity 或位置值的 CSS 變數進行動畫
  • 不要對被繼承的 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 而非 JavaScript */
/* 修改前 */ 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 = ''; });

審查指南

  • 優先執行嚴重等級的規則(永不使用模式、工具邊界)
  • 選擇能達成意圖且渲染成本最低的方式
  • 對於任何非預設的選擇,請說明其合理使用的限制條件(表面大小、持續時間或互動需求)
  • 審查時,偏好提供可操作的建議和具體的替代方案,而非空泛的理論

關聯

  • 領域: [[設計與創造力]]
  • 類別: [[3D 與動畫]]
  • 導航: [[技能總覽]],[[首頁]]

Individual skills in this repo

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

Expert in building portfolios that actually land jobs and clients -

BEKO2210/Firstbrain

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.

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

Best practices for Remotion - Video creation in React

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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.

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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.

BEKO2210/Firstbrain

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.

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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

BEKO2210/Firstbrain

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.

BEKO2210/Firstbrain

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

相關技能