Communitygithub.com

BEKO2210/Firstbrain

审计并修复动画性能问题,包括布局抖动、合成器属性、滚动相关动画和模糊效果。当动画卡顿、过渡不流畅或审查 CSS/JS 动画性能时使用。

Firstbrain 是什么?

该技能专注于诊断和解决 UI 动画性能问题,例如布局抖动、滚动驱动动画导致的卡顿,以及不当使用模糊和滤镜效果。它提供了一套清晰的规则(从“禁止模式”到“工具边界”),帮助开发者避免常见的性能陷阱,并优先使用 `transform` 和 `opacity` 等合成器属性。该技能支持在对话中审查特定文件,或作为持续约束应用于所有动画相关的工作。它兼容 CSS 动画、Web Animations API (WAAPI)、Motion、`requestAnimationFrame` 和 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 或尺寸测量的组件

渲染步骤术语表

  • 合成: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. 绘制(中高)

  • 只允许在小而孤立的元素上进行触发绘制的动画
  • 不要在大型容器上为高绘制消耗的属性添加动画
  • 不要为 transform、opacity 或 position 相关的 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 代替 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 = ''; });

审查指导

  • 首先执行严重规则(禁止模式、工具边界)
  • 选择与意图匹配的最低渲染代价方案
  • 对于任何非默认选择,说明其合理边界(元素表面大小、持续时间或交互需求)
  • 审查时,优先提供可操作的建议和具体替代方案,而非理论

关联

  • 领域: [[设计与创意]]
  • 分类: [[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

相关技能