Index of every page on this site: llms.txt
All skills
notedit avatar

/gsap-animation

@9a2d593
by leeoxiangnotedit/happy-skills341 stars
40
Run it yourself

GSAP + Remotion integration for professional motion graphics video production. Timeline orchestration, text splitting, SVG morphing, advanced easing, and reusable effect presets.

Use this Skill: https://skilld.dev/gh/notedit/happy-skills/gsap-animation

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

rulesremotion-integration.md

≈1.5k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Core Principle

GSAP timelines are created paused and seeked to frame / fps on every frame. Remotion controls time; GSAP provides animation logic. This produces deterministic, frame-perfect video output.

Remotion Frame -> Time Conversion -> GSAP Timeline Seek
frame = 0      -> tl.seek(0)       -> start state
frame = 15     -> tl.seek(0.5)     -> 0.5s state (@ 30fps)
frame = 30     -> tl.seek(1.0)     -> 1.0s state

useGSAPTimeline Hook

function useGSAPTimeline(
  buildTimeline: (tl: gsap.core.Timeline, container: HTMLDivElement) => void
) {
  const frame = useCurrentFrame();
  const { fps } = useVideoConfig();
  const containerRef = useRef<HTMLDivElement>(null);
  const tlRef = useRef<gsap.core.Timeline | null>(null);

  // Build timeline once (paused)
  useEffect(() => {
    if (!containerRef.current) return;
    const ctx = gsap.context(() => {
      const tl = gsap.timeline({ paused: true });
      buildTimeline(tl, containerRef.current!);
      tlRef.current = tl;
    }, containerRef);
    return () => { ctx.revert(); tlRef.current = null; };
  }, []);

  // Seek to current frame
  useEffect(() => {
    if (tlRef.current) tlRef.current.seek(frame / fps);
  }, [frame, fps]);

  return containerRef;
}

useGSAPWithFonts Hook (for SplitText)

SplitText measures text dimensions, so fonts must be loaded first. Use delayRender() to block rendering until ready.

function useGSAPWithFonts(
  buildTimeline: (tl: gsap.core.Timeline, container: HTMLDivElement) => void
) {
  const frame = useCurrentFrame();
  const { fps } = useVideoConfig();
  const containerRef = useRef<HTMLDivElement>(null);
  const tlRef = useRef<gsap.core.Timeline | null>(null);
  const [handle] = useState(() => delayRender());

  useEffect(() => {
    document.fonts.ready.then(() => {
      if (!containerRef.current) return;
      const ctx = gsap.context(() => {
        const tl = gsap.timeline({ paused: true });
        buildTimeline(tl, containerRef.current!);
        tlRef.current = tl;
      }, containerRef);
      continueRender(handle);
      return () => { ctx.revert(); };
    });
  }, []);

  useEffect(() => {
    if (tlRef.current) tlRef.current.seek(frame / fps);
  }, [frame, fps]);

  return containerRef;
}

Determinism Rules

  1. Always paused + seek -- never tl.play(), never tl.resume()
  2. No real-time deps -- no Date.now(), setTimeout, requestAnimationFrame, gsap.ticker
  3. Seeded randomness -- no Math.random() or gsap.utils.random(); use seeded PRNG
  4. No stateful callbacks -- avoid onUpdate that accumulates state
  5. No interactive plugins -- no Draggable, Observer, Inertia, ScrollTrigger
  6. No live DOM measurement -- pre-calculate in build phase, not per-frame
  7. Pure function of frame -- same frame number always produces same visual
// Seeded random for deterministic "random" values
function seededRandom(seed: number): number {
  const x = Math.sin(seed) * 10000;
  return x - Math.floor(x);
}

// Deterministic stagger (instead of from: "random")
tl.from(items, {
  y: 100, opacity: 0,
  stagger: (index) => seededRandom(index * 7919) * 0.5,
});

Timeline Duration to Remotion Frames

// Calculate Composition durationInFrames from GSAP timeline
const tl = gsap.timeline({ paused: true });
// ... build timeline ...
const totalSeconds = tl.totalDuration();
const durationInFrames = Math.ceil(totalSeconds * fps);

Performance Tips

  1. Build once, seek per frame -- timeline in useEffect([], []), seek in useEffect([frame])
  2. Use gsap.context() -- scopes animations to container, enables clean revert
  3. Use React.memo for static containers around animated elements
  4. Use <Freeze> for elements after their animation completes
  5. Keep timelines under ~100 tweens -- seek() resolves all tweens at position
  6. Prefer transforms over filters -- filter: blur() is slow without GPU
  7. SplitText: split once in build phase, not per-frame

Combining GSAP + Remotion interpolate()

Use GSAP for complex sequences, Remotion interpolate() for simple properties:

const MyScene: React.FC = () => {
  const frame = useCurrentFrame();

  // Simple fade via Remotion native (no GSAP needed)
  const bgOpacity = interpolate(frame, [0, 15], [0, 1], { extrapolateRight: 'clamp' });

  // Complex text sequence via GSAP
  const containerRef = useGSAPTimeline((tl, container) => {
    tl.from(container.querySelectorAll('.char'), {
      opacity: 0, y: 50, rotationX: -90,
      stagger: 0.05, duration: 0.8, ease: 'back.out(1.7)',
    });
  });

  return (
    <AbsoluteFill style={{ opacity: bgOpacity }}>
      <div ref={containerRef}>...</div>
    </AbsoluteFill>
  );
};

Flickering Prevention (Parallel Rendering)

Remotion renders frames in multiple browser tabs in parallel. Each tab:

  • Creates its own component instance
  • Builds its own GSAP timeline
  • Seeks independently

This works correctly because:

  • Timeline construction is deterministic (same props = same timeline)
  • seek() is stateless (same time = same output)
  • No cross-frame state dependency

Avoid:

  • useState for animation values (derive from useCurrentFrame())
  • Global mutable state
  • GSAP's ticker or global timeline

Audio Sync

Use Remotion's <Audio> + <Sequence> for frame-synced audio:

<AbsoluteFill>
  <Audio src={staticFile('bgm.mp3')} volume={0.5} />
  <Sequence from={30} durationInFrames={60}>
    <Audio src={staticFile('whoosh.mp3')} volume={0.8} />
  </Sequence>
  <GSAPAnimatedScene />
</AbsoluteFill>

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo5 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    The skill provides comprehensive documentation and reusable code for creating motion graphics by integrating GSAP with Remotion. It focuses on timeline orchestration, text animations, and SVG effects. No malicious patterns, exfiltration attempts, or security vulnerabilities were found.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

  • Runlayer9mo

    1/5 files flagged

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 9a2d593. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 9 months ago
Other metadata
metadata
{
  "tags": "gsap, remotion, motion-graphics, animation, video, text-animation, svg, timeline, easing"
}

README badge

README badge for notedit/happy-skills/gsap-animation