Function

useTimelineState

Reads the current synchronized TimelineStateSnapshot snapshot.

Usage notes

Use `useTimelineState` for low-frequency product chrome that needs a broad view of timeline content, viewport, playback, markers, or edit feedback without calling engine methods. The returned snapshot updates when TimelineProvider receives engine state events. Prefer narrower hooks when a component only needs one live value. For example, use useTimelinePlayheadTime for playback readouts and useTimelineViewport for viewport controls. See React editor hooks for the hook selection guide.

State available

AreaFieldsUse for
Contenttracks, clipGroups, contentRevisionTrack lists, clip counts, inspectors, and content-change badges.
Playback and timeplayheadTime, playing, playbackRate, durationToolbar state and coarse playback status. Use useTimelinePlayheadTime() for live readouts.
ViewportzoomScale, scrollLeft, scrollTop, viewportWidth, viewportHeightViewport-aware chrome. Use viewport hooks for focused scroll and zoom controls.
Selection and rangesinPoint, outPointRange labels, loop region state, and edit selection chrome.
MarkersmarkersMarker lists and annotation panels.
Interaction feedbacksnapEnabled, snapThresholdPixels, snapFeedback, clipDropFeedbackSnapping toggles, drag/drop hints, and lightweight editor status.

Signature

Type Definition
useTimelineState(): object

Returns

object

The latest `TimelineStateSnapshot` snapshot published by `TimelineProvider`.

Return members

NameSignatureDescription
clipDropFeedbackclipDropFeedback: objectTransient cross-track clip drop feedback for the active body drag interaction.
clipGroupsclipGroups: typeOperatorClip groups edited as linked units.
contentRevisioncontentRevision: numberMonotonic counter incremented when track or clip edits can change active layer lookup at a fixed playhead.
duration?duration?: { r: number; v: number }Explicit duration of the timeline. If set, this overrides the dynamic duration calculated from clips.
inPoint?inPoint?: { r: number; v: number }Optional current selection region In-Point boundary.
markers?markers?: typeOperatorList of markers positioned on the timeline.
outPoint?outPoint?: { r: number; v: number }Optional current selection region Out-Point boundary.
playbackRate?playbackRate?: numberPlayback speed multiplier (1.0 = normal speed).
playheadTimeplayheadTime: { r: number; v: number }The current playhead position.
playing?playing?: booleanCurrent playback state of the timeline.
scrollLeftscrollLeft: numberHorizontal scroll offset in pixels.
scrollTopscrollTop: numberVertical scroll offset in pixels.
snapEnabledsnapEnabled: booleanWhether magnetic snapping is globally enabled.
snapFeedbacksnapFeedback: { lines: typeOperator; target: object | null }Transient snap guide feedback for the active interaction.
snapThresholdPixelssnapThresholdPixels: numberMagnetic snap radius in screen pixels.
trackstracks: typeOperatorActive set of tracks.
viewportHeight?viewportHeight?: numberHeight of the visible timeline area in pixels (for frustum culling/virtualization).
viewportWidth?viewportWidth?: numberWidth of the visible timeline area in pixels (for frustum culling/virtualization).
zoomScalezoomScale: numberZoom scale representing pixels per second.

Examples

tsx Example
import { useTimelineState } from '@techsquidtv/canvas-timeline-react';
export function TimelineStatus() {
const state = useTimelineState();
return (
<dl>
<dt>Tracks</dt>
<dd>{state.tracks.length}</dd>
<dt>Playback</dt>
<dd>{state.playing ? 'Playing' : 'Paused'}</dd>
<dt>Zoom</dt>
<dd>{state.zoomScale}px/s</dd>
</dl>
);
}