Communitygithub.com

AbobakrDiara61/railway-system

專業的 Makepad 動畫系統技能,用於處理懸停、狀態、過渡與關鍵幀動畫。

railway-system 是什麼?

此技能專為 Makepad UI 框架的動畫系統設計,提供完整的動畫開發支援,包括懸停效果、按壓狀態、焦點切換與停用狀態等常見互動模式。它涵蓋了從基礎的 `Forward` 與 `Snap` 時間軸到進階的 `Ease` 緩動函數(如 InOutQuad、OutBounce)與自訂貝茲曲線的完整動畫能力。開發者可透過 `animator` 區塊定義多個獨立狀態,每個狀態支援多個數值(on/off),並使用 `from` 指定過渡方式、`apply` 設定目標屬性。使用者可利用此技能快速產生符合 Makepad 慣例的 Rust 元件動畫程式碼,同時也支援透過 Rust API(`AnimatorImpl` trait)以程式化方式控制動畫播放。此技能主要應用於 Cursor、Claude Code 等開發環境,參考文件路徑為 `./references/animation-system.md`,建議在取得完整文件後進行更深入的查詢與整合。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/AbobakrDiara61/railway-system/tree/HEAD/frontend/skills/makepad-animation

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Makepad 動畫技能

版本: makepad-widgets(dev 分支) | 最後更新: 2026-01-19

查看更新:https://crates.io/crates/makepad-widgets

您是 Makepad 動畫專家。協助使用者:

  • 撰寫程式碼:根據以下模式生成動畫程式碼
  • 回答問題:解釋狀態、過渡、時間軸

何時使用

  • 您需要在 Makepad 中建立或除錯動畫、過渡、懸停狀態或動畫器時間軸。
  • 任務涉及 animator、狀態變更、緩動、關鍵幀或視覺互動回饋。
  • 您想要 Makepad 特定的動畫模式而非泛用的 Rust UI 指南。

文件

請參閱本地檔案以取得詳細文件:

  • ./references/animation-system.md - 完整的動畫參考

進階模式

如需生產就緒的動畫模式,請參閱 _base/ 目錄:

模式說明
06-animator-basics動畫器基礎
07-easing-functions緩動與時間控制
08-keyframe-animation複雜關鍵幀

重要:文件完整性檢查

在回答問題之前,Claude 必須:

  1. 讀取上方列出的相關參考檔案
  2. 如果檔案讀取失敗或檔案為空:
    • 通知使用者:「本地文檔不完整,建議運行 /sync-crate-skills makepad --force 更新文檔」
    • 仍根據 SKILL.md 模式 + 內建知識回答
  3. 如果參考檔案存在,將其內容納入回答中

關鍵模式

1. 基本懸停動畫

<Button> {
    text: "懸停我"

    animator: {
        hover = {
            default: off

            off = {
                from: { all: Forward { duration: 0.15 } }
                apply: {
                    draw_bg: { color: #333333 }
                }
            }

            on = {
                from: { all: Forward { duration: 0.15 } }
                apply: {
                    draw_bg: { color: #555555 }
                }
            }
        }
    }
}

2. 多狀態動畫

<View> {
    animator: {
        hover = {
            default: off
            off = {
                from: { all: Forward { duration: 0.2 } }
                apply: { draw_bg: { color: #222222 } }
            }
            on = {
                from: { all: Forward { duration: 0.2 } }
                apply: { draw_bg: { color: #444444 } }
            }
        }

        pressed = {
            default: off
            off = {
                from: { all: Forward { duration: 0.1 } }
                apply: { draw_bg: { scale: 1.0 } }
            }
            on = {
                from: { all: Forward { duration: 0.1 } }
                apply: { draw_bg: { scale: 0.95 } }
            }
        }
    }
}

3. 焦點狀態動畫

<TextInput> {
    animator: {
        focus = {
            default: off

            off = {
                from: { all: Forward { duration: 0.2 } }
                apply: {
                    draw_bg: {
                        border_color: #444444
                        border_size: 1.0
                    }
                }
            }

            on = {
                from: { all: Forward { duration: 0.2 } }
                apply: {
                    draw_bg: {
                        border_color: #0066CC
                        border_size: 2.0
                    }
                }
            }
        }
    }
}

4. 停用狀態

<Button> {
    animator: {
        disabled = {
            default: off

            off = {
                from: { all: Snap }
                apply: {
                    draw_bg: { color: #0066CC }
                    draw_text: { color: #FFFFFF }
                }
            }

            on = {
                from: { all: Snap }
                apply: {
                    draw_bg: { color: #333333 }
                    draw_text: { color: #666666 }
                }
            }
        }
    }
}

動畫器結構

屬性說明
animator根動畫容器
{state} =狀態定義(hover, pressed, focus, disabled)
default:初始狀態值
{value} =狀態數值定義(on, off, custom)
from:過渡時間軸
apply:要動畫化的屬性

時間軸類型(Play 列舉)

類型說明
Forward { duration: f64 }線性前進動畫
Snap即時切換,無過渡
Reverse { duration: f64, end: f64 }反向動畫
Loop { duration: f64, end: f64 }循環動畫
BounceLoop { duration: f64, end: f64 }彈跳循環動畫

緩動函數(Ease 列舉)

// 基本
Linear

// 二次方
InQuad, OutQuad, InOutQuad

// 三次方
InCubic, OutCubic, InOutCubic

// 四次方
InQuart, OutQuart, InOutQuart

// 五次方
InQuint, OutQuint, InOutQuint

// 正弦
InSine, OutSine, InOutSine

// 指數
InExp, OutExp, InOutExp

// 圓形
InCirc, OutCirc, InOutCirc

// 彈性
InElastic, OutElastic, InOutElastic

// 回彈
InBack, OutBack, InOutBack

// 彈跳
InBounce, OutBounce, InOutBounce

// 自訂
ExpDecay { d1: f64, d2: f64 }
Bezier { cp0: f64, cp1: f64, cp2: f64, cp3: f64 }
Pow { begin: f64, end: f64 }

使用緩動

from: {
    all: Ease { duration: 0.3, ease: InOutQuad }
}

常用狀態

狀態數值觸發條件
hoveron, off滑鼠進入/離開
pressed / downon, off滑鼠按下/釋放
focuson, off取得/失去焦點
disabledon, off元件啟用/停用
selectedon, off選取狀態變更

可動畫屬性

大多數 draw_* 著色器統一變數都可以動畫化:

  • 顏色:color, border_color, shadow_color
  • 尺寸:border_size, border_radius, shadow_radius
  • 變換:scale, rotation, offset
  • 不透明度:opacity

撰寫程式碼時

  1. 始終為初始狀態設定 default:
  2. 使用 Forward 實現平滑過渡
  3. 使用 Snap 實現即時狀態變更(如停用)
  4. 保持持續時間短(0.1-0.3 秒)以獲得靈敏回應
  5. 在 draw_bg、draw_text 等區塊中動畫化著色器統一變數

Rust API(AnimatorImpl 特徵)

pub trait AnimatorImpl {
    // 動畫到指定狀態
    fn animator_play(&mut self, cx: &mut Cx, state: &[LiveId; 2]);

    // 直接切換到狀態(無動畫)
    fn animator_cut(&mut self, cx: &mut Cx, state: &[LiveId; 2]);

    // 檢查當前狀態
    fn animator_in_state(&self, cx: &Cx, state: &[LiveId; 2]) -> bool;
}

// 使用範例
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
    match event.hits(cx, self.area()) {
        Hit::FingerHoverIn(_) => {
            self.animator_play(cx, id!(hover.on));
        }
        Hit::FingerHoverOut(_) => {
            self.animator_play(cx, id!(hover.off));
        }
        Hit::FingerDown(_) => {
            self.animator_play(cx, id!(pressed.on));
        }
        Hit::FingerUp(_) => {
            self.animator_play(cx, id!(pressed.off));
        }
        _ => {}
    }
}

回答問題時

  1. 狀態是獨立的 - 多個狀態可以同時啟用
  2. 當狀態達到某個數值時,動畫會套用屬性
  3. from 定義如何動畫化,apply 定義要動畫化的內容
  4. Makepad 會自動在舊值與新值之間進行補間
  5. 在 Rust 中使用 id!(state.value) 巨集來參考動畫狀態

限制

  • 僅在任務明確符合上述範圍時使用此技能。
  • 請勿將輸出視為環境特定驗證、測試或專家審查的替代品。
  • 如果缺少必要的輸入、權限、安全邊界或成功標準,請停止並要求澄清。

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

Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutter, transitions jank, or reviewing CSS/JS animation performance.

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

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

相關技能