Communitygithub.com

govindgoel2001/video-editing-toolkit

GSAP 動画參考指南,專為 HyperFrames 設計。涵蓋 gsap.to()、from()、fromTo()、緩動、交錯、預設值、時間軸(gsap.timeline()、位置參數、標籤、巢狀、播放控制)以及效能最佳化(變形、will-change、quickTo)。適用於在 HyperFrames 合成中編寫 GSAP 動畫。

video-editing-toolkit 是什麼?

此技能提供了一份全面的 GSAP (GreenSock Animation Platform) 參考指南,專門針對在 HyperFrames 平台上使用 GSAP 製作動畫的需求。它詳細說明了核心補間方法(如 `gsap.to()`、`gsap.from()` 和 `gsap.fromTo()`)、常見的變數配置(包括持續時間、延遲、緩動和交錯效果),以及各種 CSS 和變形屬性的對應方式。開發者可以藉此快速查找 GSAP 的語法與最佳實踐,從而有效率地在 HyperFrames 專案中建立流暢的動畫。 除了基礎語法,該指南還深入介紹了時間軸(Timelines)的高級用法,例如使用位置參數精確控制動畫的播放順序、為關鍵時間點添加標籤,以及創建巢狀時間軸來組織複雜的動畫序列。此外,它提供了關於提升動畫效能的寶貴建議,包括優先使用變換和透明度屬性、合理設定 `will-change` 屬性,以及利用 `gsap.quickTo()` 方法處理需要頻繁更新的動畫(如跟隨滑鼠移動)。最後,指南還列出了開發者應避免的常見誤區和清理資源的重要性,確保動畫在元件卸載時能正確終止。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/govindgoel2001/video-editing-toolkit/tree/HEAD/vendor/hyperframes-skills/gsap

在你喜歡的 AI 中提問

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

說明文件

GSAP

核心補間方法

  • gsap.to(targets, vars) — 從當前狀態動畫到 vars 指定的狀態。最常用。
  • gsap.from(targets, vars) — 從 vars 指定的狀態動畫到當前狀態(入場效果)。
  • gsap.fromTo(targets, fromVars, toVars) — 明確指定起始和結束狀態。
  • gsap.set(targets, vars) — 立即應用樣式(持續時間為 0)。

請始終使用駝峰式 (camelCase) 屬性名稱(例如 backgroundColor、rotationX)。

常用變數

  • duration — 持續時間,單位秒(預設 0.5)。
  • delay — 延遲時間,單位秒。
  • ease — 緩動函數,如 "power1.out"(預設)、"power3.inOut"、"back.out(1.7)"、"elastic.out(1, 0.3)"、"none"。
  • stagger — 交錯時間,可為數字 0.1 或物件:{ amount: 0.3, from: "center" }、{ each: 0.1, from: "random" }。
  • overwrite — 覆蓋模式,false(預設)、true 或 "auto"。
  • repeat — 重複次數,數字或 -1 表示無限循環。yoyo — 搭配 repeat 使用,來回往復。
  • onComplete、onStart、onUpdate — 回呼函數。
  • immediateRender — 對於 from()/fromTo() 預設為 true。若後續補間動畫目標為相同屬性與元素,應設為 false 以避免被覆蓋。

變形與 CSS

建議使用 GSAP 的變形別名,而非原生的 transform 字串:

GSAP 屬性對應 CSS 屬性
x、y、ztranslateX/Y/Z (px)
xPercent、yPercenttranslateX/Y (%)
scale、scaleX、scaleYscale
rotationrotate (deg)
rotationX、rotationY3D rotate
skewX、skewYskew
transformOrigintransform-origin
  • autoAlpha — 優先於 opacity。當值為 0 時,會同時設定 visibility: hidden。
  • CSS 變數 — 使用 "--hue": 180。
  • svgOrigin (僅 SVG) — 全域 SVG 座標空間的原點。請勿與 transformOrigin 同時使用。
  • 方向性旋轉 — 使用 "360_cw"、"-170_short"、"90_ccw"。
  • clearProps — 設為 "all" 或以逗號分隔,動畫結束時清除行內樣式。
  • 相對值 — 使用 "+=20"、"-=10"、"*=2"。

基於函數的值

gsap.to(".item", {
  x: (i, target, targets) => i * 50,
  stagger: 0.1,
});

緩動函數

內建緩動:power1–power4、back、bounce、circ、elastic、expo、sine。每種都有 .in、.out、.inOut 三種模式。

預設值

gsap.defaults({ duration: 0.6, ease: "power2.out" });

控制補間動畫

const tween = gsap.to(".box", { x: 100 });
tween.pause();
tween.play();
tween.reverse();
tween.kill();
tween.progress(0.5);
tween.time(0.2);

gsap.matchMedia() (響應式 + 無障礙)

僅在媒體查詢條件符合時執行設定;當條件不再符合時會自動復原。

let mm = gsap.matchMedia();
mm.add(
  {
    isDesktop: "(min-width: 800px)",
    reduceMotion: "(prefers-reduced-motion: reduce)",
  },
  (context) => {
    const { isDesktop, reduceMotion } = context.conditions;
    gsap.to(".box", {
      rotation: isDesktop ? 360 : 180,
      duration: reduceMotion ? 0 : 2,
    });
  },
);

時間軸

建立時間軸

const tl = gsap.timeline({ defaults: { duration: 0.5, ease: "power2.out" } });
tl.to(".a", { x: 100 }).to(".b", { y: 50 }).to(".c", { opacity: 0 });

位置參數

第三個參數控制放置位置:

  • 絕對:1 — 在 1 秒處
  • 相對:"+=0.5" — 在結尾之後;"-=0.2" — 在結尾之前
  • 標籤:"intro"、"intro+=0.3"
  • 對齊:"<" — 與上一個補間動畫同時開始;">" — 在上一個補間動畫結束後開始;"<0.2" — 在上一個補間動畫開始後 0.2 秒
tl.to(".a", { x: 100 }, 0);
tl.to(".b", { y: 50 }, "<"); // 與 .a 同時開始
tl.to(".c", { opacity: 0 }, "<0.2"); // 在 .b 開始後 0.2 秒

標籤

tl.addLabel("intro", 0);
tl.to(".a", { x: 100 }, "intro");
tl.addLabel("outro", "+=0.5");
tl.play("outro");
tl.tweenFromTo("intro", "outro");

時間軸選項

  • paused: true — 建立時暫停;呼叫 .play() 來啟動。
  • repeat、yoyo — 套用至整個時間軸。
  • defaults — 設定後,會合併到每一個子補間動畫中。

巢狀時間軸

const master = gsap.timeline();
const child = gsap.timeline();
child.to(".a", { x: 100 }).to(".b", { y: 50 });
master.add(child, 0);

播放控制

tl.play()、tl.pause()、tl.reverse()、tl.restart()、tl.time(2)、tl.progress(0.5)、tl.kill()。


效能

優先使用變形與透明度屬性

動畫化 x、y、scale、rotation、opacity 可在合成器層級處理。當變形可以達到相同效果時,應避免使用 width、height、top、left。

will-change

will-change: transform;

僅套用在實際會產生動畫的元素上。

gsap.quickTo() 處理頻繁更新

let xTo = gsap.quickTo("#id", "x", { duration: 0.4, ease: "power3" }),
  yTo = gsap.quickTo("#id", "y", { duration: 0.4, ease: "power3" });
container.addEventListener("mousemove", (e) => {
  xTo(e.pageX);
  yTo(e.pageY);
});

交錯效果優於多個補間動畫

使用 stagger 來取代多個帶有手動延遲的補間動畫。

清理資源

暫停或終止畫面外的動畫。


參考資料(按需載入)

  • references/effects.md — 即用型效果:打字機文字、音訊可視化。當需要 HyperFrames 的現成效果模板時閱讀。

最佳實踐

  • 使用駝峰式屬性名稱;優先使用變形別名和 autoAlpha。
  • 使用時間軸而非串聯 delay;善用位置參數。
  • 使用 addLabel() 添加標籤以獲得清晰的序列。
  • 在建構函式中傳入預設值。
  • 儲存補間/時間軸的回傳值以便控制播放。

應避免事項

  • 當變形可以滿足需求時,不要動畫化佈局屬性(width/height/top/left)。
  • 不要在相同的 SVG 元素上同時使用 svgOrigin 和 transformOrigin。
  • 當時間軸可以序列化動畫時,不要使用 delay 來串聯動畫。
  • 不要在 DOM 存在之前建立補間動畫。
  • 不要忽略清理工作 — 在不需要時務必終止所有補間動畫。

Individual skills in this repo

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

govindgoel2001/video-editing-toolkit

HyperFrames CLI tool — hyperframes init, lint, inspect, preview, render, transcribe, tts, doctor, browser, info, upgrade, compositions, docs, benchmark. Use when scaffolding a project, linting, validating, inspecting visual layout in compositions, previewing in the studio, rendering to video, transcribing audio, generating TTS, or troubleshooting the HyperFrames environment.

govindgoel2001/video-editing-toolkit

Install and wire registry blocks and components into HyperFrames compositions. Use when running hyperframes add, installing a block or component, wiring an installed item into index.html, or working with hyperframes.json. Covers the add command, install locations, block sub-composition wiring, component snippet merging, and registry discovery.

govindgoel2001/video-editing-toolkit

Create video compositions, animations, title cards, overlays, captions, voiceovers, audio-reactive visuals, and scene transitions in HyperFrames HTML. Use when asked to build any HTML-based video content, add captions or subtitles synced to audio, generate text-to-speech narration, create audio-reactive animation (beat sync, glow, pulse driven by music), add animated text highlighting (marker sweeps, hand-drawn circles, burst lines, scribble, sketchout), or add transitions between scenes (crossfades, wipes, reveals, shader transitions). Covers composition authoring, timing, media, and the full video production workflow. For CLI commands (init, lint, preview, render, transcribe, tts) see the hyperframes-cli skill.

govindgoel2001/video-editing-toolkit

Capture a website and create a HyperFrames video from it. Use when: (1) a user provides a URL and wants a video, (2) someone says "capture this site", "turn this into a video", "make a promo from my site", (3) the user wants a social ad, product tour, or any video based on an existing website, (4) the user shares a link and asks for any kind of video content. Even if the user just pastes a URL — this is the skill to use.

govindgoel2001/video-editing-toolkit

Edit any video by conversation. Transcribe, cut, color grade, generate overlay animations, burn subtitles — for talking heads, montages, tutorials, travel, interviews. No presets, no menus. Ask questions, confirm the plan, execute, iterate, persist. Production-correctness rules are hard; everything else is artistic freedom.

govindgoel2001/video-editing-toolkit

Production pipeline for mathematical and technical animations using Manim Community Edition. Creates 3Blue1Brown-style explainer videos, algorithm visualizations, equation derivations, architecture diagrams, and data stories. Use when users request: animated explanations, math animations, concept visualizations, algorithm walkthroughs, technical explainers, 3Blue1Brown style videos, or any programmatic animation with geometric/mathematical content.

相關技能