Function

useTimelineState

Reads the current synchronized TimelineState 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(): TimelineState

Returns

TimelineState

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

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>
);
}