Communitygithub.com

zroeschen/Video-Production-Factory

GSAP 动画参考,适用于 HyperFrames。涵盖 gsap.to()、from()、fromTo()、缓动、错开、默认值、时间线(gsap.timeline()、位置参数、标签、嵌套、播放控制)以及性能优化(变换、will-change、quickTo)。在编写 HyperFrames 中的 GSAP 动画时使用。

Video-Production-Factory 是什么?

此技能为使用 GSAP(GreenSock 动画平台)在 HyperFrames 中创作动画的开发者和 AI 代理提供了全面的参考指南。它涵盖了核心补间方法,如 gsap.to()、gsap.from()、gsap.fromTo() 以及 gsap.set(),并强调使用驼峰命名法。技能详细介绍了常用变量,包括持续时间、延迟、缓动函数(如 back、elastic、bounce)、错开(stagger)和重复(repeat)选项,并提供了在 CSS 和 SVG 上下文中使用变换别名(如 x、y、scale、rotation)和 autoAlpha 的指导。主要功能之一是完整的时间线(Timeline)文档,包括使用位置参数进行精确排序、添加和管理标签、嵌套时间线以及掌控播放。该技能还涵盖了关键的性能优化技术:优先使用变换和不透明度、合理使用 will-change、用 gsap.quickTo() 实现高效更新、使用错开代替多个补间,以及正确清理动画。此外,它还包括用于响应式设计和无障碍支持的 gsap.matchMedia(),并提供最佳实践和常见错误避免建议。此技能适用于 HyperFrames、Claude Code、Cursor、Codex 以及任何支持 Agent 技能工具的 AI 编码代理。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/zroeschen/Video-Production-Factory/tree/HEAD/.agents/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)。

始终使用 驼峰命名法 的属性名称(例如 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 (度)
rotationX, rotationY3D 旋转
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。
  • 优先使用时间线,而非链式调用加延迟;使用位置参数。
  • 使用 addLabel() 添加标签,以便于可读的序列编排。
  • 在时间线构造函数中传入默认值。
  • 在需要控制播放时,存储补间/时间线的返回值。

禁止事项

  • 当变换足够时,不要动画布局属性(width/height/top/left)。
  • 不要在同一 SVG 元素上同时使用 svgOrigin 和 transformOrigin。
  • 当时间线可以排序动画时,不要使用延迟链式调用。
  • 不要在 DOM 存在之前创建补间。
  • 不要跳过清理工作——在不再需要时始终销毁补间。

Individual skills in this repo

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

zroeschen/Video-Production-Factory

Agent 2 of the video editing pipeline. Finds and removes spoken mistakes — stutters, repeated words, false starts, and retakes (re-recorded lines) — from a talking-head recording. Use after cut-silences, when asked to cut mistakes, remove stutters / repeats / filler restarts, clean up flubs, or keep the best take. Works review-gated: it proposes every cut with context and a reason for approval, then renders only the approved cuts via ffmpeg. Requires a word-level transcript.

zroeschen/Video-Production-Factory

Agent 1 of the video editing pipeline. Removes silences and dead air from a talking-head recording. Use when asked to cut silences, trim pauses, remove dead air / gaps, or tighten the pacing of a raw video, given a word-level transcript. Produces an edit list (EDL), a re-timed transcript for downstream agents, and optionally the cut video via ffmpeg. Does NOT cut mistakes, repeats, or false starts — that is the cut-mistakes agent.

zroeschen/Video-Production-Factory

Edit a raw talking-head video through transcription, silence trimming, mistake review, visual storytelling, motion graphics, and verified HyperFrames rendering. Use for a complete edit; route a single requested operation directly to its specialist skill.

zroeschen/Video-Production-Factory

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

相关技能