GSAP
HyperFrames Contract
HyperFrames controls GSAP through its gsap runtime adapter. Create a paused timeline synchronously, register it on window.__timelines with the exact data-composition-id, and let HyperFrames seek it.
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<script>
window.__timelines = window.__timelines || {};
const tl = gsap.timeline({ paused: true });
tl.from(".title", { y: 48, opacity: 0, duration: 0.6, ease: "power3.out" }, 0);
tl.to(".accent", { scaleX: 1, duration: 0.5, ease: "power2.out" }, 0.25);
window.__timelines["main"] = tl; // key must equal data-composition-id on the composition root
</script>
- The registry key must match the composition root's
data-composition-id.
- Do not call
tl.play() for render-critical motion.
- Do not build timelines inside async code, timers, or event handlers.
- Keep loops finite. HyperFrames renders finite video durations.
Core Tween Methods
- gsap.to(targets, vars) — animate from current state to
vars. Most common.
- gsap.from(targets, vars) — animate from
vars to current state (entrances).
- gsap.fromTo(targets, fromVars, toVars) — explicit start and end.
- gsap.set(targets, vars) — apply immediately (duration 0).
Always use camelCase property names (e.g. backgroundColor, rotationX).
Common vars
- duration — seconds (default 0.5).
- delay — seconds before start.
- ease —
"power1.out" (default), "power3.inOut", "back.out(1.7)", "elastic.out(1, 0.3)", "none".
- stagger — number
0.1 or object: { amount: 0.3, from: "center" }, { each: 0.1, from: "random" }.
- overwrite —
false (default), true, or "auto".
- repeat — finite number; never
-1 in HyperFrames. Compute repeats from the visible duration. yoyo — alternates direction with repeat.
- onComplete, onStart, onUpdate — callbacks.
- immediateRender — default
true for from()/fromTo(). Set false on later tweens targeting the same property+element to avoid overwrite.
Transforms and CSS
Prefer GSAP's transform aliases over raw transform string:
| GSAP property |
Equivalent |
x, y, z |
translateX/Y/Z (px) |
xPercent, yPercent |
translateX/Y in % |
scale, scaleX, scaleY |
scale |
rotation |
rotate (deg) |
rotationX, rotationY |
3D rotate |
skewX, skewY |
skew |
transformOrigin |
transform-origin |
- autoAlpha — prefer over
opacity. At 0: also sets visibility: hidden.
- CSS variables —
"--hue": 180.
- svgOrigin (SVG only) — global SVG coordinate space origin. Don't combine with
transformOrigin.
- Directional rotation —
"360_cw", "-170_short", "90_ccw".
- clearProps —
"all" or comma-separated; removes inline styles on complete.
- Relative values —
"+=20", "-=10", "*=2".
Function-Based Values
gsap.to(".item", {
x: (i, target, targets) => i * 50,
stagger: 0.1,
});
Easing
Built-in eases: power1–power4, back, bounce, circ, elastic, expo, sine. Each has .in, .out, .inOut.
Defaults
gsap.defaults({ duration: 0.6, ease: "power2.out" });
Controlling Tweens
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() (Responsive + Accessibility)
Runs setup only when a media query matches; auto-reverts when it stops matching.
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,
});
},
);
Timelines
Creating a Timeline
const tl = gsap.timeline({ defaults: { duration: 0.5, ease: "power2.out" } });
tl.to(".a", { x: 100 }).to(".b", { y: 50 }).to(".c", { opacity: 0 });
Position Parameter
Third argument controls placement:
- Absolute:
1 — at 1s
- Relative:
"+=0.5" — after end; "-=0.2" — before end
- Label:
"intro", "intro+=0.3"
- Alignment:
"<" — same start as previous; ">" — after previous ends; "<0.2" — 0.2s after previous starts
tl.to(".a", { x: 100 }, 0);
tl.to(".b", { y: 50 }, "<"); // same start as .a
tl.to(".c", { opacity: 0 }, "<0.2"); // 0.2s after .b starts
Labels
tl.addLabel("intro", 0);
tl.to(".a", { x: 100 }, "intro");
tl.addLabel("outro", "+=0.5");
tl.play("outro");
tl.tweenFromTo("intro", "outro");
Timeline Options
- paused: true — create paused; call
.play() to start.
- repeat, yoyo — apply to whole timeline.
- defaults — vars merged into every child tween.
Nesting Timelines
const master = gsap.timeline();
const child = gsap.timeline();
child.to(".a", { x: 100 }).to(".b", { y: 50 });
master.add(child, 0);
Playback Control
tl.play(), tl.pause(), tl.reverse(), tl.restart(), tl.time(2), tl.progress(0.5), tl.kill().
Performance
Prefer Transform and Opacity
Animating x, y, scale, rotation, opacity stays on the compositor. Avoid width, height, top, left when transforms achieve the same effect.
will-change
will-change: transform;
Only on elements that actually animate.
gsap.quickTo() for Frequent Updates
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 > Many Tweens
Use stagger instead of separate tweens with manual delays.
Cleanup
Pause or kill off-screen animations.
References (loaded on demand)
| File |
When to read it |
| references/effects.md |
Ready-made effect patterns: typewriter text, audio visualizer. |
| references/plugins.md |
Any GSAP plugin work: SplitText (per-char/word/line text animation), DrawSVG (stroke draw-on), MorphSVG (shape morph), MotionPath (move along a path), Flip (layout-state transitions), CustomEase / CustomWiggle / CustomBounce (camera shake, custom curves), Physics2D / PhysicsProps (projectiles, confetti), ScrambleText, GSDevTools, Pixi. CDN registration recipe included. |
| references/utils.md |
gsap.utils helpers: distribute (grid/cascade value spreads), interpolate, mapRange / normalize / clamp, snap, wrap / wrapYoyo, splitColor, toArray / selector / pipe, random (with the determinism caveat). |
The plugin and utils references are vendored from the official greensock/gsap-skills (MIT) with HyperFrames adaptation headers — read those headers first; upstream examples assume interactive pages, not seek-driven renders.
Best Practices
- Use camelCase property names; prefer transform aliases and autoAlpha.
- Prefer timelines over chaining with delay; use the position parameter.
- Add labels with
addLabel() for readable sequencing.
- Pass defaults into timeline constructor.
- Store tween/timeline return value when controlling playback.
Do Not
- Animate layout properties (width/height/top/left) when transforms suffice.
- Use both svgOrigin and transformOrigin on the same SVG element.
- Chain animations with delay when a timeline can sequence them.
- Create tweens before the DOM exists.
- Skip cleanup — always kill tweens when no longer needed.
- Use infinite repeat values in HyperFrames compositions. Use finite repeat counts computed from the visible duration.
Credits And References
- HyperFrames adapter source:
packages/core/src/runtime/adapters/gsap.ts.
- GSAP documentation: https://gsap.com/docs/v3/
- GSAP timeline pause and seek behavior: https://gsap.com/docs/v3/GSAP/Timeline/pause%28%29/
- Official GSAP skills (upstream of references/plugins.md and references/utils.md): https://github.com/greensock/gsap-skills (MIT, vendored at commit
aed9cfd). The upstream gsap-react, gsap-frameworks, and gsap-scrolltrigger skills are intentionally NOT vendored — compositions are vanilla single-file HTML and renders have no scroll; consult upstream directly if that ever changes.
1---2name: gsap3description: GSAP animation reference for HyperFrames. Covers gsap.to(), from(), fromTo(), easing, stagger, defaults, timelines (gsap.timeline(), position parameter, labels, nesting, playback), performance (transforms, will-change, quickTo), plugins (SplitText, DrawSVG, MorphSVG, MotionPath, Flip, CustomEase/CustomWiggle/CustomBounce, Physics2D, ScrambleText — via references/plugins.md), and gsap.utils (distribute, interpolate, snap, wrap, mapRange, splitColor — via references/utils.md). Use when writing GSAP animations in HyperFrames compositions, animating text per-char/word/line, drawing or morphing SVG, moving along a path, or distributing values across many elements.4---56# GSAP78## HyperFrames Contract910HyperFrames controls GSAP through its `gsap` runtime adapter. Create a paused timeline synchronously, register it on `window.__timelines` with the exact `data-composition-id`, and let HyperFrames seek it.1112```html13<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>14<script>15 window.__timelines = window.__timelines || {};16 const tl = gsap.timeline({ paused: true });1718 tl.from(".title", { y: 48, opacity: 0, duration: 0.6, ease: "power3.out" }, 0);19 tl.to(".accent", { scaleX: 1, duration: 0.5, ease: "power2.out" }, 0.25);2021 window.__timelines["main"] = tl; // key must equal data-composition-id on the composition root22</script>23```2425- The registry key must match the composition root's `data-composition-id`.26- Do not call `tl.play()` for render-critical motion.27- Do not build timelines inside async code, timers, or event handlers.28- Keep loops finite. HyperFrames renders finite video durations.2930## Core Tween Methods3132- **gsap.to(targets, vars)** — animate from current state to `vars`. Most common.33- **gsap.from(targets, vars)** — animate from `vars` to current state (entrances).34- **gsap.fromTo(targets, fromVars, toVars)** — explicit start and end.35- **gsap.set(targets, vars)** — apply immediately (duration 0).3637Always use **camelCase** property names (e.g. `backgroundColor`, `rotationX`).3839## Common vars4041- **duration** — seconds (default 0.5).42- **delay** — seconds before start.43- **ease** — `"power1.out"` (default), `"power3.inOut"`, `"back.out(1.7)"`, `"elastic.out(1, 0.3)"`, `"none"`.44- **stagger** — number `0.1` or object: `{ amount: 0.3, from: "center" }`, `{ each: 0.1, from: "random" }`.45- **overwrite** — `false` (default), `true`, or `"auto"`.46- **repeat** — finite number; never `-1` in HyperFrames. Compute repeats from the visible duration. **yoyo** — alternates direction with repeat.47- **onComplete**, **onStart**, **onUpdate** — callbacks.48- **immediateRender** — default `true` for from()/fromTo(). Set `false` on later tweens targeting the same property+element to avoid overwrite.4950## Transforms and CSS5152Prefer GSAP's **transform aliases** over raw `transform` string:5354| GSAP property | Equivalent |55| --------------------------- | ------------------- |56| `x`, `y`, `z` | translateX/Y/Z (px) |57| `xPercent`, `yPercent` | translateX/Y in % |58| `scale`, `scaleX`, `scaleY` | scale |59| `rotation` | rotate (deg) |60| `rotationX`, `rotationY` | 3D rotate |61| `skewX`, `skewY` | skew |62| `transformOrigin` | transform-origin |6364- **autoAlpha** — prefer over `opacity`. At 0: also sets `visibility: hidden`.65- **CSS variables** — `"--hue": 180`.66- **svgOrigin** _(SVG only)_ — global SVG coordinate space origin. Don't combine with `transformOrigin`.67- **Directional rotation** — `"360_cw"`, `"-170_short"`, `"90_ccw"`.68- **clearProps** — `"all"` or comma-separated; removes inline styles on complete.69- **Relative values** — `"+=20"`, `"-=10"`, `"*=2"`.7071## Function-Based Values7273```javascript74gsap.to(".item", {75 x: (i, target, targets) => i * 50,76 stagger: 0.1,77});78```7980## Easing8182Built-in eases: `power1`–`power4`, `back`, `bounce`, `circ`, `elastic`, `expo`, `sine`. Each has `.in`, `.out`, `.inOut`.8384## Defaults8586```javascript87gsap.defaults({ duration: 0.6, ease: "power2.out" });88```8990## Controlling Tweens9192```javascript93const tween = gsap.to(".box", { x: 100 });94tween.pause();95tween.play();96tween.reverse();97tween.kill();98tween.progress(0.5);99tween.time(0.2);100```101102## gsap.matchMedia() (Responsive + Accessibility)103104Runs setup only when a media query matches; auto-reverts when it stops matching.105106```javascript107let mm = gsap.matchMedia();108mm.add(109 {110 isDesktop: "(min-width: 800px)",111 reduceMotion: "(prefers-reduced-motion: reduce)",112 },113 (context) => {114 const { isDesktop, reduceMotion } = context.conditions;115 gsap.to(".box", {116 rotation: isDesktop ? 360 : 180,117 duration: reduceMotion ? 0 : 2,118 });119 },120);121```122123---124125## Timelines126127### Creating a Timeline128129```javascript130const tl = gsap.timeline({ defaults: { duration: 0.5, ease: "power2.out" } });131tl.to(".a", { x: 100 }).to(".b", { y: 50 }).to(".c", { opacity: 0 });132```133134### Position Parameter135136Third argument controls placement:137138- **Absolute**: `1` — at 1s139- **Relative**: `"+=0.5"` — after end; `"-=0.2"` — before end140- **Label**: `"intro"`, `"intro+=0.3"`141- **Alignment**: `"<"` — same start as previous; `">"` — after previous ends; `"<0.2"` — 0.2s after previous starts142143```javascript144tl.to(".a", { x: 100 }, 0);145tl.to(".b", { y: 50 }, "<"); // same start as .a146tl.to(".c", { opacity: 0 }, "<0.2"); // 0.2s after .b starts147```148149### Labels150151```javascript152tl.addLabel("intro", 0);153tl.to(".a", { x: 100 }, "intro");154tl.addLabel("outro", "+=0.5");155tl.play("outro");156tl.tweenFromTo("intro", "outro");157```158159### Timeline Options160161- **paused: true** — create paused; call `.play()` to start.162- **repeat**, **yoyo** — apply to whole timeline.163- **defaults** — vars merged into every child tween.164165### Nesting Timelines166167```javascript168const master = gsap.timeline();169const child = gsap.timeline();170child.to(".a", { x: 100 }).to(".b", { y: 50 });171master.add(child, 0);172```173174### Playback Control175176`tl.play()`, `tl.pause()`, `tl.reverse()`, `tl.restart()`, `tl.time(2)`, `tl.progress(0.5)`, `tl.kill()`.177178---179180## Performance181182### Prefer Transform and Opacity183184Animating `x`, `y`, `scale`, `rotation`, `opacity` stays on the compositor. Avoid `width`, `height`, `top`, `left` when transforms achieve the same effect.185186### will-change187188```css189will-change: transform;190```191192Only on elements that actually animate.193194### gsap.quickTo() for Frequent Updates195196```javascript197let xTo = gsap.quickTo("#id", "x", { duration: 0.4, ease: "power3" }),198 yTo = gsap.quickTo("#id", "y", { duration: 0.4, ease: "power3" });199container.addEventListener("mousemove", (e) => {200 xTo(e.pageX);201 yTo(e.pageY);202});203```204205### Stagger > Many Tweens206207Use `stagger` instead of separate tweens with manual delays.208209### Cleanup210211Pause or kill off-screen animations.212213---214215## References (loaded on demand)216217| File | When to read it |218|---|---|219| [references/effects.md](references/effects.md) | Ready-made effect patterns: typewriter text, audio visualizer. |220| [references/plugins.md](references/plugins.md) | Any GSAP plugin work: SplitText (per-char/word/line text animation), DrawSVG (stroke draw-on), MorphSVG (shape morph), MotionPath (move along a path), Flip (layout-state transitions), CustomEase / CustomWiggle / CustomBounce (camera shake, custom curves), Physics2D / PhysicsProps (projectiles, confetti), ScrambleText, GSDevTools, Pixi. CDN registration recipe included. |221| [references/utils.md](references/utils.md) | gsap.utils helpers: distribute (grid/cascade value spreads), interpolate, mapRange / normalize / clamp, snap, wrap / wrapYoyo, splitColor, toArray / selector / pipe, random (with the determinism caveat). |222223The plugin and utils references are vendored from the official [greensock/gsap-skills](https://github.com/greensock/gsap-skills) (MIT) with HyperFrames adaptation headers — read those headers first; upstream examples assume interactive pages, not seek-driven renders.224225## Best Practices226227- Use camelCase property names; prefer transform aliases and autoAlpha.228- Prefer timelines over chaining with delay; use the position parameter.229- Add labels with `addLabel()` for readable sequencing.230- Pass defaults into timeline constructor.231- Store tween/timeline return value when controlling playback.232233## Do Not234235- Animate layout properties (width/height/top/left) when transforms suffice.236- Use both svgOrigin and transformOrigin on the same SVG element.237- Chain animations with delay when a timeline can sequence them.238- Create tweens before the DOM exists.239- Skip cleanup — always kill tweens when no longer needed.240- Use infinite repeat values in HyperFrames compositions. Use finite repeat counts computed from the visible duration.241242## Credits And References243244- HyperFrames adapter source: `packages/core/src/runtime/adapters/gsap.ts`.245- GSAP documentation: https://gsap.com/docs/v3/246- GSAP timeline pause and seek behavior: https://gsap.com/docs/v3/GSAP/Timeline/pause%28%29/247- Official GSAP skills (upstream of references/plugins.md and references/utils.md): https://github.com/greensock/gsap-skills (MIT, vendored at commit `aed9cfd`). The upstream `gsap-react`, `gsap-frameworks`, and `gsap-scrolltrigger` skills are intentionally NOT vendored — compositions are vanilla single-file HTML and renders have no scroll; consult upstream directly if that ever changes.