Communitygithub.com

CharbelElBateh/personal-website

從零開始建構動畫,按照順序決定每個環節是否合理——是否應該動畫、目的為何、使用哪種工具、哪些屬性、曲線和持續時間、如何中斷、如何退出。並撰寫實作程式碼。在需要為元件添加動畫、動作、使其感覺鮮活,或建構過渡效果時使用。若要評論現有動畫,請使用 review-animations;若要審查整個程式碼庫,請使用 improve-animations。

personal-website 是什麼?

這是一個專門用於建構動畫的 AI 技能,遵循 Emil Kowalski 的動畫哲學,旨在產生能通過嚴格審查的實作。它並非用於審計程式碼庫或評論差異,而是專注於單一任務:將動畫請求轉化為高品質的實作。技能的核心運作流程包含七個階段:判斷是否應該動畫、命名動畫目的、選擇最簡單的工具(從 CSS 過渡到 Motion 函式庫)、選擇正確的屬性(僅 transform 和 opacity)、選擇合適的曲線和持續時間(有明確的對照表)、處理中斷和退出、以及處理減少動畫偏好和懸停門控。此技能支援常見 UI 元件(如按鈕、下拉選單、工具提示、模態框、抽屜、通知)的動畫建構,並提供預製的配方。它特別強調避免常見錯誤,例如使用 transition: all、scale(0)、ease-in、過長持續時間等。最終輸出包含程式碼以及簡潔的門控結果、配料清單和感覺檢查建議。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/CharbelElBateh/personal-website/tree/HEAD/.claude/skills/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)、在通知上使用關鍵影格、使用讓下拉選單感覺遲緩的持續時間。

絕不將動畫選項作為選單呈現。做出決定,用一行陳述理由,然後撰寫程式碼。

硬性規則

  1. 按順序執行流程。 步驟 1 和 2 門控一切。在確定是否要動畫之前,不要考慮曲線。
  2. 無近似值。 每個曲線、持續時間和彈簧設定都來自下方的表格。永遠不要憑感覺發明 cubic-bezier(0.4, 0, 0.2, 1)。
  3. 擴展程式碼庫的 tokens,不要另起爐灶。 如果 --ease-out 或持續時間尺度已存在,請使用它。新增一個平行系統是缺陷。
  4. 減少動畫偏好和懸停門控應與動畫一同提供,而不是作為後續補充。
  5. 使用最簡單且能解決問題的工具。 不要為了淡入效果而安裝動畫函式庫。

建構流程

1. 這個東西到底該不該動畫化?

頻率決定
每天 100 次以上(鍵盤快捷鍵、指令面板切換)永遠不要動畫。 在此停止。
每天數十次(懸停效果、列表導航)僅限幾乎無法察覺的動畫——快速且微妙,否則就不要動
偶爾(模態框、抽屜、通知)標準動畫
罕見 / 首次(引導流程、成功、慶祝)愉悅預算在此處使用

鍵盤觸發的動作是 disqualifier(一票否決),而非判斷問題。 Raycast 沒有開啟/關閉動畫——對於每天開啟數百次的東西來說,這是正確的。

如果請求未通過此門控,請直言不諱,不要撰寫動畫。改為提供非動畫的替代方案(即時狀態變更、靜態視覺提示)。

2. 目的是什麼?

在繼續之前,用以下其中一個詞彙命名目的:

  • 回饋——確認介面已接收到使用者的操作
  • 空間一致性——顯示某物從哪裡來或到哪裡去
  • 狀態指示——讓狀態變更易於理解
  • 防止突兀的變化——橋接原本會瞬間切換的內容
  • 解釋——展示某物如何運作(僅限行銷/引導流程)
  • 愉悅——僅 允許在罕見/首次層級

無法命名目的?就不要建構它。「看起來很酷」在一個頻繁看到的元素上,是停止的理由。

同時檢查功能:使用者正在閱讀或操作中的資料,不應為了樣式而移動。裝飾性的滑鼠追蹤效果應屬於行銷頁面,而非銀行應用程式中的圖表。

3. 選擇工具——選最簡單且能解決問題的

逐項檢查;停在第一個符合的選項。

需求工具
懸停、按下、顏色、可透過 class 或 attribute 控制的狀態切換CSS transition
掛載時的進場動畫,無 JS 狀態CSS @starting-style
預先確定的動畫,需在頁面忙碌載入時保持流暢CSS animation(在主執行緒之外運行)
需要程式控制且具 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 }        // Apple 風格——更容易理解
{ type: "spring", mass: 1, stiffness: 100, damping: 10 }  // 傳統物理——更多控制

將 bounce 保持在 0.1–0.3,並避免在大多數 UI 中使用 bounce——將其保留給拖曳關閉和 playful 的互動。

6. 中斷和退出

  • 對於快速觸發的項目使用 transitions,而非 keyframes——通知、切換開關、任何使用者可以在一秒內觸發兩次的東西。Transitions 從當前值重新定位;Keyframes 從零重新開始。
  • 手勢使用彈簧,因為它們能在中斷時保持速度。
  • 以進入的方式退出。 從底部滑入的通知應從底部離開。對稱路徑是讓滑動關閉感覺直覺的原因。
  • 在使用者正在決策的地方使用不對稱時序。 在需要深思的階段慢(按住確認按鈕按住:2s 線性),在系統響應階段快(鬆開: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+ 次的動作使用動畫不要動畫
UI 持續時間超過 300ms 且無理由150–250ms
錨定於觸發點的彈出視窗使用 transform-origin: centervar(--transform-origin)(模態框除外)
通知、切換開關、快速觸發的元素使用 KeyframesCSS transitions
動畫化 width/height/margin/padding/top/lefttransform / opacity
負載下使用 Motion 的 x/y/scale props完整 transform 字串
未經門控的 :hover 動畫@media (hover: hover) and (pointer: fine)
缺少 prefers-reduced-motion更溫和的變體,不是歸零
所有東西同時進入30–80ms 交錯

輸出

撰寫程式碼。然後,最多用幾行文字:

  • 門控結果——頻率層級和命名後的目的。如果請求中的某些東西被拒絕,請說明哪個以及為什麼。
  • 配料——工具、屬性、曲線、持續時間或彈簧設定,每項一行。
  • 需要感覺檢查的內容——如果結果取決於你無法從程式碼判斷的感覺(例如交叉淡入、彈簧的 bounce、進入列表中透明度/高度的平衡),請說明並指出檢查方法:以 2–5 倍持續時間播放或在 DevTools 動畫檢查器中播放、逐影格檢查、在真實裝置上測試手勢、以及隔天用全新的眼光再看一次。

不要將此擴充成報告。程式碼才是交付物。

語氣

獨斷且簡潔。當誠實的答案是「這不該動畫化」時,就說出來——這個答案正是此技能存在的理由。當感覺確實無法從程式碼判斷時,就說出來,而不是猜測一個值。

Individual skills in this repo

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

CharbelElBateh/personal-website

Build animations in React Native and Expo, making the decisions in the order that determines whether they feel right — should it animate, which thread it runs on, which properties, spring or timing, how the gesture hands off, how it degrades. Writes the implementation with Reanimated, Gesture Handler, Expo Router and expo-haptics. Use when animating anything in an Expo app, adding gestures, sheets, screen transitions, press feedback or haptics, or fixing motion that stutters on device. For web animation use `animate`.

CharbelElBateh/personal-website

Reverse-lookup glossary that turns a vague description of a web animation or motion effect into its exact term ("the bouncy thing when a popover opens" → Pop in; "the iOS rubber-band scroll" → Rubber-banding). Use when the user asks "what's it called when…", or describes a motion effect without knowing its name and wants the right word to prompt an AI or designer with. For naming an effect, not designing or building one.

CharbelElBateh/personal-website

Apple's approach to interface design and fluid, physical motion, translated for the web. Use when building or reviewing gesture-driven UI, spring animations, drag/swipe/sheet interactions, momentum and interruptible transitions, translucent materials and depth, typography (optical sizing, tracking, leading), reduced-motion, or the design foundations (feedback, spatial consistency, restraint) behind Apple-style interfaces.

CharbelElBateh/personal-website

Guide to Sonner, the React toast library — install and wire up the Toaster, pick the right toast() call, promise and loading toasts, updating, dismissing and persisting toasts, styling, theming and icons, positioning and multiple toasters. Use when working with Sonner or troubleshooting it — toasts that don't appear, appear twice, lose their styles, ignore Tailwind classes, sit behind a modal, or don't follow dark mode.

CharbelElBateh/personal-website

Try to break a piece of UI by feeding it worst-case data — long names, unbreakable emails, one-letter names, missing fields, huge counts, zero items, long labels, non-Latin text, emoji, extreme numbers — then render it behind a "Demo data / Worst case" toggle and report everything that broke, with the fix for each. Use when the user asks to stress-test, break, or find edge cases in a component or screen, or to "try the worst case". For visual design critique use emil-design-eng; for motion use review-animations.

CharbelElBateh/personal-website

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

CharbelElBateh/personal-website

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.

CharbelElBateh/personal-website

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.

CharbelElBateh/personal-website

Make a web app feel native on a phone — the small CSS and meta-tag fixes that separate "a website in a browser" from something that feels installed. Covers sticky hover states, tap highlight flashes, the 100vh bug, inputs that zoom the page, laggy taps, pull-to-refresh hijacking scroll, content under the notch, long-press selecting button text, carousels that scroll the wrong way, mismatched status bars, and the rule that you test on real hardware. Use when a web app is being built for or reviewed on mobile, when something "works in Chrome but feels wrong on my phone", when building a PWA, a bottom sheet, a carousel, a full-screen layout, or any touch interaction. For motion itself use animate; for React Native use animate-expo.

CharbelElBateh/personal-website

Pick the right library for a given frontend task from a curated, opinionated list — numbers, OTP inputs, charts, command menus, virtualization, drag and drop, toasts, state, styling, and more. Only runs when explicitly invoked; it does not trigger on its own.

CharbelElBateh/personal-website

Build multiple genuinely different versions of a UI piece you describe, rendered behind a visual picker so you can flip through them live and promote the one that feels right. Only runs when explicitly invoked; it does not trigger on its own.

CharbelElBateh/personal-website

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

CharbelElBateh/personal-website

How to write modern Swift well — modeling with value types, Swift 6 data-race safety and approachable concurrency (@concurrent, main-actor-by-default, actors, task groups), protocols and generics (some vs any), API design, performance and ARC, Swift Testing, macros, and the modern language features agents don't know about yet. Use when writing, reviewing, or migrating Swift, or when a concurrency error, a hang, a data race, a retain cycle, or a performance problem needs fixing.

相關技能