Communitygithub.com

AbobakrDiara61/railway-system

对动画性能问题进行审计和修复,包括布局抖动、合成器属性、滚动绑定动画和模糊效果。在动画卡顿、过渡不流畅或审核 CSS/JS 动画性能时使用。

railway-system 是什么?

该技能旨在帮助开发者和 AI 代理诊断并修复 Web 动画中的性能问题,尤其适用于 CSS、JavaScript、WAAPI、Motion、rAF、GSAP 等动画库。它通过一套优先级明确的规则(从“绝不模式”到“工具边界”)来引导用户避免性能陷阱,例如混排布局读写、触发频繁重绘、依赖滚动事件驱动动画等。支持在代码审查、重构或实施新动画时使用,并特别强调优先使用 transform 和 opacity 合成属性、使用 Scroll/View Timelines 替代滚动轮询、以及通过 FLIP 技术减少布局计算。该技能不要求迁移动画库,而是在现有技术栈内应用规则,并提供具体的代码级修复建议。

兼容平台~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 或测量的组件

渲染步骤词汇表

  • composite(合成):transform, opacity
  • paint(绘制):颜色、边框、渐变、遮罩、图像、滤镜
  • layout(布局):尺寸、位置、流、网格、弹性

规则类别(按优先级)

优先级类别影响程度
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 控制可见性和暂停
  • 不要轮询滚动位置进行动画
  • 屏幕外时暂停或停止动画
  • 滚动绑定动画不得在大型表面上触发持续布局或绘制

5. 绘制(中-高)

  • 仅允许在小型、孤立的元素上进行触发 paint(绘制)的动画
  • 不要在大型容器上对 paint 密集型属性进行动画
  • 不要对用于 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 = ''; });

审查指导

  • 首先强制实施严重规则(绝不模式、工具边界)
  • 选择与意图匹配且渲染开销最小的方式
  • 对于任何非默认选择,说明其约束条件(表面大小、持续时间或交互需求)
  • 审查时,优先提供可操作的说明和具体替代方案,而非理论

限制

  • 仅在任务明显符合上述范围时使用此技能。
  • 不要将输出视为具体环境验证、测试或专家评审的替代。
  • 如果缺少必需的输入、权限、安全边界或成功标准,请停止并要求澄清。

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

相关技能