
Gsap
- 75 installs
- Updated July 24, 2026
- chanjing-ai/framevideo
This is a copy of gsap by heygen-com - installs and ranking accrue to the original listing.
Helps with ai & agent building tasks.
About
gsap is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted development.
- gsap
- AI & Agent Building
- AI-coding skill
Gsap by the numbers
- 75 all-time installs (skills.sh)
- Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/chanjing-ai/framevideo --skill gsapAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 75 |
|---|---|
| Last updated | July 24, 2026 |
| Repository | chanjing-ai/framevideo ↗ |
What it does
Helps with ai & agent building tasks.
Files
GSAP
FrameVideo Contract
FrameVideo 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 FrameVideo 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. FrameVideo 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
varsto 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.1or object:{ amount: 0.3, from: "center" },{ each: 0.1, from: "random" }. - overwrite —
false(default),true, or"auto". - repeat — finite number; never
-1in FrameVideo. Compute repeats from the visible duration. yoyo — alternates direction with repeat. - onComplete, onStart, onUpdate — callbacks.
- immediateRender — default
truefor from()/fromTo(). Setfalseon 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 setsvisibility: 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 startsLabels
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)
- [references/effects.md](references/effects.md) — Drop-in effects: typewriter text, audio visualizer. Read when needing ready-made effect patterns for FrameVideo.
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 FrameVideo compositions. Use finite repeat counts computed from the visible duration.
Credits And References
- FrameVideo 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/
GSAP Effects for FrameVideo
Drop-in animation patterns for FrameVideo compositions. Each effect is self-contained with HTML, CSS, and code.
All effects follow FrameVideo composition rules — deterministic, no randomness, timelines registered via window.__timelines.
Table of Contents
---
Typewriter
Reveal text character by character using GSAP's TextPlugin.
Required Plugin
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/TextPlugin.min.js"></script>
<script>
gsap.registerPlugin(TextPlugin);
</script>Basic Typewriter
const text = "Hello, world!";
const cps = 10; // chars per second: 3-5 dramatic, 8-12 conversational, 15-20 energetic
tl.to(
"#typed-text",
{ text: { value: text }, duration: text.length / cps, ease: "none" },
startTime,
);With Blinking Cursor
Three rules:
1. One cursor visible at a time — hide previous before showing next. 2. Cursor must blink when idle — after typing, during pauses. 3. No gap between text and cursor — elements must be flush in HTML.
<span id="typed-text"></span><span id="cursor" class="cursor-blink">|</span>@keyframes blink {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0;
}
}
.cursor-blink {
animation: blink 0.8s step-end infinite;
}
.cursor-solid {
animation: none;
opacity: 1;
}
.cursor-hide {
animation: none;
opacity: 0;
}Pattern: blink → solid (typing starts) → type → solid → blink (typing done).
tl.call(() => cursor.classList.replace("cursor-blink", "cursor-solid"), [], startTime);
tl.to("#typed-text", { text: { value: text }, duration: dur, ease: "none" }, startTime);
tl.call(() => cursor.classList.replace("cursor-solid", "cursor-blink"), [], startTime + dur);Backspacing
TextPlugin removes from front — wrong for backspace. Use manual substring removal:
function backspace(tl, selector, word, startTime, cps) {
const el = document.querySelector(selector);
const interval = 1 / cps;
for (let i = word.length - 1; i >= 0; i--) {
tl.call(
() => {
el.textContent = word.slice(0, i);
},
[],
startTime + (word.length - i) * interval,
);
}
return word.length * interval;
}Spacing with Static Text
When a typewriter word sits next to static text, use margin-left on a wrapper span. Don't use flex gap (spaces cursor from text) or trailing space in static text (collapses when dynamic is empty).
<div style="display:flex; align-items:baseline;">
<span style="font-size:40px; color:#555;">Ship something</span>
<span style="margin-left:14px;"><span id="word"></span><span id="cursor">|</span></span>
</div>Word Rotation
Type → hold → backspace → next word. Cursor blinks during every idle moment (holds, after backspace).
words.forEach((word, i) => {
const typeDur = word.length / 10;
// Solid while typing
tl.call(() => cursor.classList.replace("cursor-blink", "cursor-solid"), [], offset);
tl.to("#typed-text", { text: { value: word }, duration: typeDur, ease: "none" }, offset);
// Blink during hold
tl.call(() => cursor.classList.replace("cursor-solid", "cursor-blink"), [], offset + typeDur);
offset += typeDur + 1.5; // hold
if (i < words.length - 1) {
tl.call(() => cursor.classList.replace("cursor-blink", "cursor-solid"), [], offset);
const clearDur = backspace(tl, el, word, offset, 20);
tl.call(() => cursor.classList.replace("cursor-solid", "cursor-blink"), [], offset + clearDur);
offset += clearDur + 0.3;
}
});Appending Words
Build a sentence word-by-word into the same element:
let accumulated = "";
words.forEach((word) => {
const target = accumulated + (accumulated ? " " : "") + word;
const newChars = target.length - accumulated.length;
tl.to("#typed-text", { text: { value: target }, duration: newChars / 10, ease: "none" }, offset);
accumulated = target;
offset += newChars / 10 + 0.3;
});Multi-Line Cursor Handoff
When handing off between typewriter lines: hide previous → blink new → pause → solid when typing. Never go hidden→solid (skips idle state).
tl.call(
() => {
prevCursor.classList.replace("cursor-blink", "cursor-hide");
nextCursor.classList.replace("cursor-hide", "cursor-blink");
},
[],
handoffTime,
);
const typeStart = handoffTime + 0.5; // brief blink pause
tl.call(() => nextCursor.classList.replace("cursor-blink", "cursor-solid"), [], typeStart);
tl.to("#next-text", { text: { value: text }, duration: dur, ease: "none" }, typeStart);
tl.call(() => nextCursor.classList.replace("cursor-solid", "cursor-blink"), [], typeStart + dur);Timing Guide
| CPS | Feel | Good for |
|---|---|---|
| 3-5 | Slow, deliberate | Dramatic reveals, suspense |
| 8-12 | Natural typing | Dialogue, narration |
| 15-20 | Fast, energetic | Tech demos, code |
| 30+ | Near-instant | Filling long blocks |
---
Audio Visualizer
Pre-extract audio data, drive canvas/DOM rendering from GSAP timeline.
Extract Audio Data
python scripts/extract-audio-data.py audio.mp3 -o audio-data.json
python scripts/extract-audio-data.py video.mp4 --fps 30 --bands 16 -o audio-data.jsonRequires ffmpeg and numpy.
Data Format
{
"fps": 30, "totalFrames": 5415,
"frames": [{ "time": 0.0, "rms": 0.42, "bands": [0.8, 0.6, 0.3, ...] }]
}- rms (0-1): overall loudness, normalized across track
- bands[] (0-1): frequency magnitudes. Index 0 = bass, higher = treble. Each normalized independently.
Loading the Data
// Option A: inline (small files, under ~500KB)
var AUDIO_DATA = {
/* paste audio-data.json contents */
};
// Option B: sync XHR (large files — must be synchronous for deterministic timeline construction)
var xhr = new XMLHttpRequest();
xhr.open("GET", "audio-data.json", false);
xhr.send();
var AUDIO_DATA = JSON.parse(xhr.responseText);Do NOT use async `fetch()` to load audio data. FrameVideo requires synchronous timeline construction — the capture engine reads window.__timelines synchronously after page load. Building timelines inside .then() callbacks means the timeline isn't ready when capture starts.
Rendering Approaches
Canvas 2D (most common — bars, waveforms, circles, gradients):
for (let f = 0; f < AUDIO_DATA.totalFrames; f++) {
tl.call(
() => {
const frame = AUDIO_DATA.frames[f];
ctx.clearRect(0, 0, canvas.width, canvas.height);
// draw using frame.rms and frame.bands
},
[],
f / AUDIO_DATA.fps,
);
}WebGL / Three.js — FrameVideo patches THREE.Clock for deterministic time. Update uniforms from audio data each frame.
DOM Elements — fine for < 20 elements, less performant than Canvas for many.
Spatial Mapping
- Horizontal: bass left, treble right (iterate bands left-to-right)
- Vertical: bass bottom, treble top
- Circular: bass at 12 o'clock, wrap clockwise; mirror for full circle
Smoothing
let prev = null;
const smoothing = 0.25; // 0.1-0.2 snappy, 0.3-0.5 flowing
function smooth(f) {
const raw = AUDIO_DATA.frames[f];
if (!prev) {
prev = { rms: raw.rms, bands: [...raw.bands] };
return prev;
}
prev = {
rms: prev.rms * smoothing + raw.rms * (1 - smoothing),
bands: raw.bands.map((b, i) => prev.bands[i] * smoothing + b * (1 - smoothing)),
};
return prev;
}Motion Principles
- Bass drives big moves — scale, glow, position shifts
- Treble drives detail — shimmer, flicker, edge effects
- RMS drives globals — background brightness, overall energy
- Pick 2-3 properties to animate. More looks noisy.
- Keep minimums above zero — quiet sections need life.
Band Count
| Bands | Detail | Good for |
|---|---|---|
| 4 | Low | Background glow, pulsing |
| 8 | Medium | Bar charts, basic spectrum |
| 16 | High | Detailed EQ (default) |
| 32 | Very high | Dense radial layouts |
Layering
Layer multiple canvases with CSS z-index for depth — a background layer driven by bass/rms and a foreground layer driven by individual bands creates depth without complexity.
<canvas id="bg-layer" style="position:absolute;top:0;left:0;z-index:1;"></canvas>
<canvas id="main-layer" style="position:absolute;top:0;left:0;z-index:2;"></canvas>#!/usr/bin/env python3
"""
Extract per-frame audio visualization data from an audio or video file.
Outputs JSON with RMS amplitude and frequency band data at the target FPS,
ready to embed in a FrameVideo composition.
Usage:
python extract-audio-data.py input.mp3 -o audio-data.json
python extract-audio-data.py input.mp4 --fps 30 --bands 16 -o audio-data.json
Requirements:
- Python 3.9+
- ffmpeg (for decoding audio)
- numpy (pip install numpy)
"""
import argparse
import json
import subprocess
import sys
import numpy as np
# ---------------------------------------------------------------------------
# FFT parameters
#
# A 4096-sample window gives ~10.8 Hz per bin at 44100Hz — enough to resolve
# low-frequency bands cleanly. The per-frame audio slice (44100/30 = 1470
# samples at 30fps) is too small and causes low bands to map to the same bins.
#
# Frequency range 30Hz–16kHz covers the useful range for music. Below 30Hz is
# sub-bass most speakers can't reproduce; above 16kHz is noise/harmonics that
# don't contribute to perceived rhythm or melody.
# ---------------------------------------------------------------------------
SAMPLE_RATE = 44100
FFT_SIZE = 4096
MIN_FREQ = 30.0
MAX_FREQ = 16000.0
def decode_audio(path: str) -> np.ndarray:
"""Decode audio to mono float32 samples via ffmpeg."""
cmd = [
"ffmpeg", "-i", path,
"-vn", "-ac", "1", "-ar", str(SAMPLE_RATE),
"-f", "s16le", "-acodec", "pcm_s16le",
"-loglevel", "error",
"pipe:1",
]
result = subprocess.run(cmd, capture_output=True)
if result.returncode != 0:
print(f"ffmpeg error: {result.stderr.decode()}", file=sys.stderr)
sys.exit(1)
return np.frombuffer(result.stdout, dtype=np.int16).astype(np.float32) / 32768.0
def compute_band_edges(n_bands: int) -> np.ndarray:
"""Logarithmically-spaced frequency band edges from MIN_FREQ to MAX_FREQ."""
return np.array([
MIN_FREQ * (MAX_FREQ / MIN_FREQ) ** (i / n_bands)
for i in range(n_bands + 1)
])
def compute_fft_bands(
windowed: np.ndarray, freq_per_bin: float, n_bins: int,
band_edges: np.ndarray, n_bands: int,
) -> np.ndarray:
"""Compute peak magnitude in logarithmically-spaced frequency bands."""
magnitudes = np.abs(np.fft.rfft(windowed))
bands = np.zeros(n_bands)
for b in range(n_bands):
low_bin = max(0, int(band_edges[b] / freq_per_bin))
high_bin = min(n_bins, int(band_edges[b + 1] / freq_per_bin))
if high_bin <= low_bin:
high_bin = low_bin + 1
# Clamp to valid range to avoid empty slices
low_bin = min(low_bin, n_bins - 1)
high_bin = min(high_bin, n_bins)
bands[b] = np.max(magnitudes[low_bin:high_bin])
return bands
def extract(path: str, fps: int, n_bands: int) -> dict:
"""Extract per-frame audio data."""
print(f"Decoding audio from {path}...", file=sys.stderr)
samples = decode_audio(path)
duration = len(samples) / SAMPLE_RATE
frame_step = SAMPLE_RATE // fps
total_frames = int(duration * fps)
print(f"Duration: {duration:.1f}s, {total_frames} frames at {fps}fps", file=sys.stderr)
print(f"FFT window: {FFT_SIZE} samples ({SAMPLE_RATE / FFT_SIZE:.1f} Hz/bin)", file=sys.stderr)
print(f"Frequency range: {MIN_FREQ:.0f}-{MAX_FREQ:.0f} Hz, {n_bands} bands", file=sys.stderr)
# Precompute constants
hann = np.hanning(FFT_SIZE)
band_edges = compute_band_edges(n_bands)
freq_per_bin = SAMPLE_RATE / FFT_SIZE
n_bins = FFT_SIZE // 2 + 1
half_fft = FFT_SIZE // 2
# Pass 1: extract raw values
rms_values = np.zeros(total_frames)
band_values = np.zeros((total_frames, n_bands))
for f in range(total_frames):
# RMS from the frame's audio slice
rms_start = f * frame_step
rms_end = rms_start + frame_step
frame_slice = samples[rms_start:min(rms_end, len(samples))]
if len(frame_slice) > 0:
rms_values[f] = np.sqrt(np.mean(frame_slice ** 2))
# FFT from a centered 4096-sample window
center = rms_start + frame_step // 2
win_start = center - half_fft
win_end = center + half_fft
if win_start >= 0 and win_end <= len(samples):
window = samples[win_start:win_end] * hann
else:
# Zero-pad at edges
padded = np.zeros(FFT_SIZE)
src_start = max(0, win_start)
src_end = min(len(samples), win_end)
dst_start = src_start - win_start
dst_end = dst_start + (src_end - src_start)
padded[dst_start:dst_end] = samples[src_start:src_end]
window = padded * hann
band_values[f] = compute_fft_bands(window, freq_per_bin, n_bins, band_edges, n_bands)
# Pass 2: normalize
peak_rms = rms_values.max() if total_frames > 0 else 1.0
if peak_rms > 0:
rms_values /= peak_rms
# Per-band normalization so treble is visible alongside louder bass
band_peaks = band_values.max(axis=0)
band_peaks[band_peaks == 0] = 1.0
band_values /= band_peaks
# Build output
frames = []
for f in range(total_frames):
frames.append({
"time": round(f / fps, 4),
"rms": round(float(rms_values[f]), 4),
"bands": [round(float(b), 4) for b in band_values[f]],
})
return {
"duration": round(duration, 4),
"fps": fps,
"bands": n_bands,
"totalFrames": total_frames,
"frames": frames,
}
def main():
parser = argparse.ArgumentParser(description="Extract per-frame audio visualization data")
parser.add_argument("input", help="Audio or video file")
parser.add_argument("-o", "--output", default="audio-data.json", help="Output JSON path")
parser.add_argument("--fps", type=int, default=30, help="Frames per second (default: 30)")
parser.add_argument("--bands", type=int, default=16, help="Number of frequency bands (default: 16)")
args = parser.parse_args()
if args.fps < 1:
parser.error("--fps must be at least 1")
if args.bands < 1:
parser.error("--bands must be at least 1")
data = extract(args.input, args.fps, args.bands)
with open(args.output, "w") as f:
json.dump(data, f)
print(f"Wrote {args.output} ({data['totalFrames']} frames, {data['bands']} bands)", file=sys.stderr)
if __name__ == "__main__":
main()