data-start, data-duration) and an optional animation attached to it. The SDK exposes typed helpers for both: the timing API controls when an element appears and how long it stays on screen; the animation API controls how it moves through that window.
Clip Timing
Reading timings
getElementTimings() returns a Record<HfId, ElementTimingSnapshot> — one entry per element that carries timing data. Values are derived from the live DOM on every call (never cached in the snapshot). Keys are scopedId: for top-level elements this equals the bare id, but for elements inside a sub-composition it is the scoped form "hf-HOST/hf-LEAF".
ElementTimingSnapshot contains:
GSAP timeline label names whose numeric position falls within
[enterAt, exitAt]. Parsed fresh
from the GSAP script on every getElementTimings() call — never stale.getElementTimings() only includes elements that have data-start and either data-duration or
data-end attributes. Untimed elements are omitted. The method prefers data-duration over
data-end − data-start when both exist, matching the behavior of setTiming.Setting timing on one element
Updating multiple elements in one batch
setElementTiming(map) dispatches one setTiming op per entry inside a single batch, so the history records one undo step and patch listeners see one event:
Elastic holds
An elastic hold freezes or loops a portion of an element’s timeline window. Use it to hold a static frame between two animated segments without changing clip duration.ElasticHold fields:
"freeze" holds the last frame until end; "loop" repeats the segment from start back to
start.GSAP Tweens
GSAP tweens are the primary animation primitive. The SDK reads tween IDs fromelement.animationIds (returned by the query API) and writes through addGsapTween, setGsapTween, and removeGsapTween.
Adding a tween
addGsapTween returns the newly-assigned animation ID as a string.
GsapTweenSpec fields
Timeline position: a number (seconds) or a label-relative string (e.g.
"intro+=0.3").
Number-only is required for addWithKeyframes / replaceWithKeyframes — see
Keyframes below.Starting values for
"from", target values for "to", or immediate values for "set".
Also supplies the destination of "fromTo" when toProperties is omitted.Modifying a tween
setGsapTween takes the animation ID and a Partial<GsapTweenSpec> — only the keys you pass are updated.
Removing a tween
Looking up animation IDs
Query the element snapshot to find animation IDs attached to a given element:Gating an op with can()
dispatch() does not run validation, so gate any op that can fail with can()
first and skip it when the result is not ok. Adding a tween or a label attaches
to a timeline — without a gsap.timeline() in the script, can() returns
E_NO_GSAP_TIMELINE:
can():
Keyframes
For keyframe-based animations, useaddWithKeyframes and replaceWithKeyframes. Both operate on the GSAP CSS-keyframes layer and return the minted animation ID.
Adding a keyframed tween
"" if the op was rejected.
Replacing an existing keyframed tween
KeyframeSpec fields
GSAP endpoint flag — when
true, this keyframe picks up the element’s current value
automatically.Lower-level keyframe and label ops
For lower-level operations — individual keyframe mutations (addGsapKeyframe, setGsapKeyframe, removeGsapKeyframe), property removal, arc paths, label insertion, and animation splitting — use dispatch() directly with the corresponding EditOp types. See the Edit Operations reference for the full op union.
Edit Operations
Full reference for every op type in the
EditOp union, including lower-level keyframe and arc
ops.Types
GsapTweenSpec, KeyframeSpec, ElasticHold, ElementTimingSnapshot, and all related types.GSAP Animation Guide
Authoring GSAP timelines in composition HTML.
Animation in Studio
Keyframe authoring patterns and best practices.