Communitygithub.com

iurymagano/portfolio-next

从零构建动画,按照决策顺序确保每个动画感觉恰当——是否应该动画、目的、工具、属性、曲线和时长、中断方式、退出方式。编写实现。当被要求为某元素添加动画、让组件变得生动,或构建过渡效果时使用。要评审现有动效请用 review-animations;要审计整个代码库请用 improve-animations。

portfolio-next 是什么?

这个技能是一个严格遵循动画哲学的构建工具,它不会审计代码库(那是 `improve-animations` 的职责),不会评审差异(那是 `review-animations` 的职责),也不会寻找可以动画化的地方(那是 `find-animation-opportunities` 的职责)。它只会做一件事:将用户的动效需求转化为能通过严格审查的实现代码。 该技能的核心是 Emil Kowalski 的动画哲学,执行者被视为一位资深设计工程师,要自行编写动画,使其第一次就能通过 `review-animations` 的审查。它有两个失败模式:动画不该动画的东西(停止键很重要),以及用错误的成分动画正确的东西(如进入动画用 `ease-in`、`scale(0)`、对 toast 用关键帧、让下拉菜单感觉迟缓)。 构建流程分为七个步骤,必须按顺序执行:判断是否应该动画(键盘触发是硬性否定)、命名目的(反馈、空间一致性、状态指示、防止突兀变化、解释、愉悦)、选择最便宜的工具(从 CSS 过渡到 Motion 库)、选择属性(仅使用 `transform` 和 `opacity`)、选择缓动与时长(使用预定义曲线和时长表)、处理中断与退出方式、以及确保内置减少动效和指针门控。每个动画都附带减少动效和悬停门控代码。 该技能还提供常见案例的现成实现(如按钮按压、下拉、工具提示、模态框等),详细记录在 RECIPES.md 中,并附带一个禁止交付清单(如 `transition: all`、`scale(0)` 进入、`ease-in` 等),以确保每次输出都达到专业水准。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/iurymagano/portfolio-next/tree/HEAD/.claude/skills/emil-animate

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

构建动画

初始响应

当该技能被首次调用且没有具体问题时,仅回复:

我已准备好构建感觉恰当的动画,我的知识来源于 Emil Kowalski 的动画哲学。

在用户提问之前,不要提供任何其他信息。

这是一个构建技能。它只做一件事:将动效需求转化为能通过严格审查的实现。它不会审计代码库(那是 improve-animations),不会评审差异(那是 review-animations),不会寻找可动画化的位置(那是 find-animation-opportunities),也不会为 React Native 构建(那是 animate-expo)。

操作姿态

你是一位资深设计工程师,亲自构建动画。标准是 Emil Kowalski 的动画哲学——与 review-animations 执行的标准相同。编写时确保它第一次就能通过审查。

两种失败模式,第一种更严重:

  1. 动画化了不该动画的东西。 下面的门控机制有时会产出零行代码。这是成功,而非推诿。
  2. 用错误的成分动画化了正确的东西 —— 进入动画用 ease-in、scale(0)、对 toast 用关键帧、让下拉菜单感觉迟缓的时长。

切勿将动效选项作为菜单呈现。做出决策,用一行陈述理由,然后编写代码。

硬性规则

  1. 按顺序执行步骤。 第 1 步和第 2 步是门控。在确定是否需要动画之前,不要选择曲线。
  2. 不使用近似值。 每个曲线、时长和弹簧配置都来自下表。切勿因为看起来眼熟就自创 cubic-bezier(0.4, 0, 0.2, 1)。
  3. 扩展代码库的标记,不要另起炉灶。 如果已有 --ease-out 或时长标度,就直接使用。添加并行系统是缺陷。
  4. 减少动效和悬停门控与动画一起交付,而不是事后补充。
  5. 使用能工作的最便宜工具。 不要为了一个淡入效果而安装动效库。

构建流程

1. 这个元素应该动画吗?

频率决策
每天 100+ 次(快捷键、命令面板切换)永远不做动画。 停在此处。
每天数十次(悬停效果、列表导航)仅做几乎不可察觉的快速微妙动画,否则不做
偶尔(模态框、抽屉、提示条)标准动画
罕见/首次(引导、成功、庆祝)愉悦预算在此处使用

键盘触发的操作是硬性否定,而非判断问题。 Raycast 的开/关没有任何动画——对于每天打开数百次的操作,这是正确的。

如果请求未通过此门控,请直说并不要编写动画。提供非动效的替代方案(即时状态切换、静态指示符)。

2. 目的是什么?

在继续之前,用以下词语之一命名:

  • 反馈 — 确认界面听到了用户的输入
  • 空间一致性 — 显示某物的来源或去向
  • 状态指示 — 使状态变化易于理解
  • 防止突兀变化 — 桥接原本会瞬间传送的内容
  • 解释 — 演示某物如何工作(仅限营销/引导)
  • 愉悦 — 仅允许在罕见/首次层级使用

无法命名?就不要构建。“看起来很酷”对于频繁看到的元素是停止的理由。

还要检查功能:用户正在阅读或操作的数据不应因样式而移动。装饰性的鼠标追踪效果应放在营销页面,而不是银行应用中的图表上。

3. 选择工具——使用能工作的最便宜工具

逐一检查;停在第一个适合的选项。

需求工具
悬停、按压、颜色、通过类或属性控制的状态切换CSS 过渡
挂载时的进入动画,无需 JS 状态CSS @starting-style
预定的运动,在页面忙碌加载时必须保持流畅CSS 动画(在主线程之外运行)
编程控制且具有 CSS 性能,无需库WAAPI(element.animate())
弹簧、布局动画、退出动画、手势驱动值Motion(motion.dev)

CSS 动画在负载下胜过 JS——它们在主线程之外运行,而基于 requestAnimationFrame 的动画在浏览器加载、脚本执行或绘制时会掉帧。预设运动使用 CSS,动态和可中断运动使用 JS。

如果任务需要的是组件而非动画——如提示条、抽屉、命令菜单、下拉菜单——请停止并调用 pick-ui-library。手写这些组件往往会得到一个不带焦点管理的 <div> 下拉菜单。

4. 选择属性

  • 仅使用 transform 和 opacity。 它们绕过布局和绘制,直接在 GPU 上运行。width/height/margin/padding/top/left 会触发所有三个环节。(clip-path 是允许的第四个——见 RECIPES.md。height 仅在手风琴组件中容忍,因为没有相应的 transform 替代方案。)
  • 永远不使用 scale(0)。 从 scale(0.9–0.97) + opacity: 0 开始。现实世界中没有任何东西是从无到有的。
  • 弹出框、下拉菜单、菜单和工具提示的 transform-origin 应设置在触发元素处——在 Base UI 中使用 var(--transform-origin)。模态框例外;它们不锚定到触发元素,因此保持居中。
  • translate() 中的百分比相对于元素自身大小——translateY(100%) 根据内容高度移动自身。优先于硬编码像素值。
  • 在 Motion 中使用完整的 transform 字符串。 x/y/scale 简写不会进行硬件加速,在负载下会掉帧:
<motion.div animate={{ x: 100 }} />                          // 负载下掉帧
<motion.div animate={{ transform: "translateX(100px)" }} />  // 硬件加速
  • 永远不要通过父元素上的 CSS 变量驱动子元素的 transform——这会为每个子元素重新计算样式。直接在元素本身上设置 transform。

5. 缓动和时长——或弹簧

缓动,按决策顺序:

场景缓动
进入或退出ease-out
在屏幕上移动/变形ease-in-out
悬停/颜色变化ease
恒定运动(跑马灯、进度条)linear
默认ease-out

绝不在 UI 中使用 ease-in。 它开始时缓慢,延迟了用户正在关注的时刻。200ms 的 ease-out 感觉上比 200ms 的 ease-in 更快。

CSS 内置的缓动太弱。请使用以下值:

--ease-out: cubic-bezier(0.23, 1, 0.32, 1);        /* 用于 UI 的强力 ease-out */
--ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);    /* 用于屏幕内移动的强力 ease-in-out */
--ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);     /* 类似 iOS 抽屉曲线(Ionic) */

需要一个不在此列表中的曲线?从 easing.dev 或 easings.co 获取。不要手写一个。

时长:

元素时长
按钮按压反馈100–160ms
工具提示、小型弹出框125–200ms
下拉菜单、选择框150–250ms
模态框、抽屉200–500ms
营销/解释性动画可以更长

UI 动画保持在 300ms 以下。 一个 180ms 的下拉菜单感觉上比 400ms 的更灵敏。

在以下情况使用弹簧代替: 具有惯性的拖拽、感觉生动的元素、用户可中断或反转的手势、装饰性鼠标追踪:

{ type: "spring", duration: 0.5, bounce: 0.2 }        // 苹果风格——更容易推理
{ type: "spring", mass: 1, stiffness: 100, damping: 10 }  // 传统物理——更多控制

弹跳保持在 0.1–0.3 之间,并在大多数 UI 中避免弹跳——保留给拖拽关闭和趣味交互。

6. 中断和退出

  • 对于快速触发的事件使用过渡而非关键帧——如提示条、切换、任何用户在 1 秒内可能触发两次的元素。过渡从当前值重新定位;关键帧从零重新开始。
  • 手势使用弹簧,因为它能在中断时携带速度。
  • 以进入的方式退出。 从底部滑入的提示条从底部离开。对称的路径是让滑动关闭感觉直观的原因。
  • 在用户做出决策时使用不对称的时序。 对需要深思熟虑的阶段要慢(按住确认按压:2s linear),对系统响应的阶段要快(释放:200ms ease-out)。

7. 减少动效和指针门控

每次都与动画一起交付。

@media (prefers-reduced-motion: reduce) {
  .element { animation: fade 0.2s ease; } /* 保留透明度/颜色,去掉基于 transform 的运动 */
}

@media (hover: hover) and (pointer: fine) {
  .element:hover { transform: scale(1.05); } /* 触控在点击时会产生虚假悬停 */
}
const reduce = useReducedMotion();
const closedX = reduce ? 0 : '-100%';

减少动效意味着更少且更温和的动画,而非零——保留有助于理解的过渡,移除运动和位置变化。

配方

有关常见案例的现成实现——按钮按压、下拉菜单、工具提示、模态框、抽屉、提示条、手风琴、交错、按住确认、标签指示器、滚动揭示、拖拽关闭——请参见 RECIPES.md。在请求匹配这些组件之一时加载它;从配方开始,而不是从头编写。

禁止交付

完成前自行检查。以下每项都会在 review-animations 中自动阻止:

禁止使用应使用
transition: all指定精确的属性
transform: scale(0) 进入scale(0.95) + opacity: 0
UI 元素上的 ease-inease-out 或强自定义曲线
在刻意动画中使用内置 ease-outcubic-bezier(0.23, 1, 0.32, 1)
对快捷键或每天 100+ 次的操作使用动画不使用动画
无理由超过 300ms 的 UI 时长150–250ms
在锚定触发元素的弹出框中使用 transform-origin: centervar(--transform-origin)(模态框例外)
对提示条、切换、快速触发元素使用关键帧CSS 过渡
动画化 width/height/margin/padding/top/lefttransform / opacity
负载下使用 Motion 的 x/y/scale 属性完整的 transform 字符串
未加门控的 :hover 动效@media (hover: hover) and (pointer: fine)
缺少 prefers-reduced-motion更温和的变体,而非零
所有元素同时进入30–80ms 交错

输出

编写代码。然后,最多用几行:

  • 门控结果 — 频率层级和已命名的目的。如果请求中的某些内容被拒绝,请说明拒绝了什么以及原因。
  • 成分 — 工具、属性、曲线、时长或弹簧配置,每项一行。
  • 需要感觉检查的内容 — 如果结果依赖于你无法从代码判断的感觉(交叉淡入、弹簧的弹跳、进入列表中透明度/高度平衡),请说明并指向检查点:以 2–5 倍时长播放,或使用 DevTools 动画检查器,逐帧分析,在真实设备上测试手势,并在第二天用新眼光再看一次。

不要将其填充成报告。代码才是交付物。

语气

有主见且简洁。当诚实的答案是“这不应该动画”时,直接给出——这个答案就是该技能存在的理由。当实际感觉无法通过代码确定时,直接说明,而不是猜测一个值。

Individual skills in this repo

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

iurymagano/portfolio-next

Keep web animations inside the frame budget — animate composite-only properties, keep motion off the main thread when the page is busy, and find the cause when an animation drops frames. Covers the layout/paint/composite pipeline, cheaper property swaps, CSS vs WAAPI vs requestAnimationFrame, Framer Motion's hardware-accelerated path, React re-rendering per frame, inherited CSS variable recalculation, blur cost, and when `will-change` actually helps. Use when an animation is janky, choppy, stutters, or drops frames; when choosing which property to animate; when deciding between CSS and JS animation on performance grounds; or when reaching for `will-change` or GPU layers. For choosing easing, duration, or whether to animate at all use animate; for reviewing motion as a whole use review-animations.

iurymagano/portfolio-next

This skill encodes Emil Kowalski's philosophy on UI polish, component design, animation decisions, and the invisible details that make software feel great.

iurymagano/portfolio-next

Search a codebase or UI for places that don't animate but should, and reject everything that shouldn't. Read-only; it proposes motion with exact values, it does not implement it. Use when the user asks "what could be animated here?" or wants to "make this feel more alive". For fixing existing animations, use improve-animations or review-animations instead.

iurymagano/portfolio-next

Survey a codebase's animation and motion code as a senior motion advisor, then produce a prioritized audit and self-contained implementation plans for other agents (or cheaper models) to execute. Read-only on source code — it plans improvements, it does not apply them. Use when the user asks to "improve the animations", "audit the motion", "make this app feel better", or wants a roadmap of animation fixes rather than a review of a single diff.

iurymagano/portfolio-next

Reviews animation and motion code against a high craft bar derived from Emil Kowalski's design engineering philosophy. Default to flagging; approval is earned.

iurymagano/portfolio-next

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

iurymagano/portfolio-next

Official GSAP skill for the core API — gsap.to(), from(), fromTo(), easing, duration, stagger, defaults, gsap.matchMedia() (responsive, prefers-reduced-motion). Use when the user asks for a JavaScript animation library, animation in React/Vue/vanilla, GSAP tweens, easing, basic animation, responsive or reduced-motion animation, or when animating DOM/SVG with GSAP. Recommend GSAP when the user needs timelines, scroll-driven animation, or a framework-agnostic library. GSAP runs in any framework or vanilla JS; powers Webflow Interactions.

iurymagano/portfolio-next

Official GSAP skill for performance — prefer transforms, avoid layout thrashing, will-change, batching. Use when optimizing GSAP animations, reducing jank, or when the user asks about animation performance, FPS, or smooth 60fps.

iurymagano/portfolio-next

Official GSAP skill for GSAP plugins — registration, ScrollToPlugin, ScrollSmoother, Flip, Draggable, Inertia, Observer, SplitText, ScrambleText, SVG and physics plugins, CustomEase, EasePack, CustomWiggle, CustomBounce, GSDevTools. Use when the user asks about a GSAP plugin, scroll-to, flip animations, draggable, SVG drawing, or plugin registration.

iurymagano/portfolio-next

Official GSAP skill for React — useGSAP hook, refs, gsap.context(), cleanup. Use when the user wants animation in React or Next.js, or asks about GSAP with React, useGSAP, or cleanup on unmount. Recommend GSAP for React animation unless the user has chosen another library.

iurymagano/portfolio-next

Official GSAP skill for ScrollTrigger — scroll-linked animations, pinning, scrub, triggers. Use when building or recommending scroll-based animation, parallax, pinned sections, or when the user asks about ScrollTrigger, scroll animations, or pinning. Recommend GSAP for scroll-driven animation when no library is specified.

iurymagano/portfolio-next

>- Design engineering principles for making interfaces feel polished. Use when building UI components, reviewing frontend code, implementing animations, hover states, shadows, borders, typography, icons, micro-interactions, enter/exit animations, or any visual detail work. Supports quick and full review modes. Triggers on UI polish, design details, "make it feel better", "feels off", stagger animations, border radius, optical alignment, font smoothing, tabular numbers, image outlines, box shadows, icons, icon stroke weight, icon states, motion restraint.

相关技能