Skip to content

The VS Code of video editing, built for agents.

TypeScript

Update documentation and examples for anime.js integration

konstantin-paulus9a4d56311c75
diff --git a/reference/jsx/errors.md b/reference/jsx/errors.md
index 3dc92067..1ba9689b 100644
--- a/reference/jsx/errors.md
+++ b/reference/jsx/errors.md
@@ -28,7 +28,7 @@ Only generations are written down this way: a load that failed is cheap to try a
A composition that looks right in the viewport but captures black, frozen, or partially missing frames is almost always one of four things — check them in this order:
-1. **A stateful animation seek.** GSAP records a tween's start values at the tween's *first* render, and captures/exports sample frames out of order — so a tween whose target was written to outside the timeline before its first render bakes that mutated state in as its starting values and replays it at every subsequent frame. Symptom: deterministic but *order-dependent* wrong frames — the same time renders when requested first and comes out wrong when requested after a later frame. See the caveat in [html.md](./html.md): give tweens explicit start values with `fromTo`, never write to or reset tween targets between seeks, and derive capture-critical values statelessly from `time()`.
+1. **A stateful animation seek.** anime.js records a tween's start values at the tween's *first* render, and captures/exports sample frames out of order — so a tween whose target was written to outside the timeline before its first render bakes that mutated state in as its starting values and replays it at every subsequent frame. Symptom: deterministic but *order-dependent* wrong frames — the same time renders when requested first and comes out wrong when requested after a later frame. See the caveat in [html.md](./html.md): give tweens explicit start values with `{ from, to }`, never write to or reset tween targets between seeks, and derive capture-critical values statelessly from `time()`.
2. **`scale()` on a large or clipped subtree.** The rasterizer renders these as empty (see [html.md limitations](./html.md#requirements-and-limitations)). Symptom: one wrapper's entire subtree missing at every sampled time while siblings render. Fix: translate/opacity animation; `scale` only on small content-sized leaves without inner clips.
3. **Fractional `opacity` nested under fractional `opacity`.** The rasterizer drops the ancestor's whole subtree while its opacity is between 0 and 1 if any descendant carries its own `opacity` < 1 (see [html.md limitations](./html.md#requirements-and-limitations)). Symptom: an element blank at every time its entrance/exit fade is mid-flight, rendering normally the moment the animated opacity reaches exactly 1 — deterministic per time and independent of sampling order. Fix: animate `opacity` on one level only; dim children with `rgba()`/`hsl()` alpha colors.
4. **`Error drawing <HtmlPaint> content: … No cached paint record for element`** in `dapi logs`, or html content missing from the first sampled frame(s) of a capture while later frames render: the offline draw raced the browser's paint snapshot for a freshly mounted host. Engine-side, not a composition bug — until the `whenReady` paint-snapshot fix ships, re-request the affected time or lead the capture with a throwaway frame.
diff --git a/reference/jsx/html.md b/reference/jsx/html.md
index ecb019e9..229cfcf6 100644
--- a/reference/jsx/html.md
+++ b/reference/jsx/html.md
@@ -2,10 +2,10 @@
An element whose children are **real HTML**: the browser lays them out at the element's box size and the result is drawn into the box via the [html-in-canvas](https://github.com/WICG/html-in-canvas) API. The Diffusion Studio app ships with this API enabled, so `<html>` is always available — reach for it liberally. It is the recommended way to build motion graphics, overlays, and any UI-heavy content: styled cards, tables, code blocks, flex/grid layouts — anything painful to assemble from `<rect>` and `<text>`.
-Driving the markup with a [GSAP](https://gsap.com) timeline is **recommended** — it keeps the animation frame-accurate: build the timeline paused, then `seek` it from the [`useTicker`](./lifecycle.md#useticker) playhead so it follows scrubbing and exports rather than the wall clock. GSAP works in seconds, so the playhead feeds `seek` directly.
+Driving the markup with an [anime.js](https://animejs.com) timeline is **recommended** — it keeps the animation frame-accurate: build the timeline with `autoplay: false`, then `seek` it from the [`useTicker`](./lifecycle.md#useticker) playhead so it follows scrubbing and exports rather than the wall clock. anime.js works in milliseconds, so the playhead is scaled by 1000 on the way into `seek`.
```tsx
-import { gsap } from "gsap";
+import { createTimeline, type Timeline } from "animejs";
import { useTicker } from "@diffusionstudio/jsx";
import { createEffect, onMount } from "solid-js";
@@ -13,17 +13,18 @@ export default function Intro() {
const { time } = useTicker();
let index!: HTMLSpanElement;
let label!: HTMLSpanElement;
- let tl!: gsap.core.Timeline;
+ let tl!: Timeline;
- // GSAP resolves targets at tween creation and refs are only assigned during
- // render, so build the timeline in onMount — it runs before the effect below.
+ // anime.js resolves targets at tween creation and refs are only assigned
+ // during render, so build the timeline in onMount — it runs before the
+ // effect below.
onMount(() => {
- tl = gsap.timeline({ paused: true })
- .fromTo(index, { opacity: 0, x: -24 }, { opacity: 1, x: 0, ease: "power1.out", duration: 0.4 })
- .fromTo(label, { opacity: 0 }, { opacity: 1, ease: "power1.out", duration: 0.4 }, "-=0.2");
+ tl = createTimeline({ autoplay: false })
+ .add(index, { opacity: { from: 0, to: 1 }, x: { from: -24, to: 0 }, ease: "outQuad", duration: 400 }, 0)
+ .add(label, { opacity: { from: 0, to: 1 }, ease: "outQuad", duration: 400 }, 200);
});
- createEffect(() => tl.seek(time()));
+ createEffect(() => tl.seek(time() * 1000));
return (
<stage camera={[0.7, 0, 0, 0.7, 90, 270]}>
@@ -41,7 +42,7 @@ export default function Intro() {
}
```
-Prefer this timeline over hand-animating styles: keep the markup static and let the paused GSAP timeline own every moving value, so one `seek` keeps the whole host frame-accurate. A static `style` may be a plain string, but one spanning multiple lines has to be a template literal in braces (`style={`…`}`), as above. Reach for a derived style only for values the timeline does not drive, and write it as a **style object** (`style={{ color: c() }}`) rather than interpolating the signal into a style string, so each property updates independently.
+Prefer this timeline over hand-animating styles: keep the markup static and let the paused anime.js timeline own every moving value, so one `seek` keeps the whole host frame-accurate. A static `style` may be a plain string, but one spanning multiple lines has to be a template literal in braces (`style={`…`}`), as above. Reach for a derived style only for values the timeline does not drive, and write it as a **style object** (`style={{ color: c() }}`) rather than interpolating the signal into a style string, so each property updates independently.
The `<html>` box carries all [common props](./elements.md#common-props). Its paint child form, [`<htmlPaint>`](./paints.md), draws the same reactive HTML onto any existing filled geometry; `<html>` is just a `<rect>` that carries one.