View, Interaction, and State API
Zoom and time indicator
setZoomLevel(zoomLevel: number): boolean
Sets an absolute zoom level. Valid values are 1.0 through 1000.0.
zoom(factor: number): void
Scales the current zoom level by a factor while trying to keep the viewport centered on the same time position.
getZoomLevel(): number
setTimeIndicator(seconds: number, applySnap = false): boolean
Moves the time indicator and scrolls it into view when needed.
Notes:
- The value is clamped between
startTimeandendTime - When
applySnapistrue, snapping uses the current zoom and scale settings - This method triggers
onTimeIndicatorMove
setTimeIndicatorDuringDrag(seconds: number): void
Lightweight variant used during dragging.
Notes:
- Triggers
timeIndicator:drag - Does not trigger
onTimeIndicatorMove - Does not trigger
onTimeIndicatorHighlight - Uses throttled edge scrolling
setEnableTimeIndicator(enabled: boolean): void
Canvas sizing and rendering
setCanvasSize(width: number, height: number): void
Sets the logical canvas size explicitly.
adjustCanvasSize(): void
Recomputes scroll bounds and runs the canvas:resize redraw pipeline.
If the container size changes, call
setCanvasSize()first to update the canvas dimensions, thenadjustCanvasSize()if you need to recompute layout state explicitly.
draw(): void
Forces an immediate draw.
getCanvas(): HTMLCanvasElement
getCanvasLogicalHeight(): number
getCachedLogicalHeight(): number
Returns the cached logical height from the render manager.
getContentWidthForZoom(zoomLevel: number): number
hasHorizontalScrollbar(): boolean
getAvailableHeight(): number
getLastLayerTimes(): Record<string, number>
Returns the per-layer timings from the most recent render.
markDirty(layers): void
Marks specific layers as dirty. The current public signature expects an explicit array of layer names.
Available layer names:
backgroundtrackstimelineguideLinesindicatorscrollbaroverlayinteraction
notifyChange(change: ChangeType): void
Use this after direct internal mutations so the scheduler can recompute derived state, mark dirty layers, and trigger any related callbacks.
Common ChangeType values:
events:add/events:update/events:delete/events:move/events:splitzoom:changetimeIndicator:move/timeIndicator:dragcanvas:resizedata:loadtheme:changeinteraction:hover/interaction:contextMenu/interaction:splitLineconfig:debug/config:timeIndicator/config:endTime/config:readOnly
beginChangeBatch(): void
endChangeBatch(): void
Batches multiple state changes into a single redraw cycle.
Hit testing and guide lines
getInteractionTarget(canvasX, canvasY): InteractionTarget
Returns track, event, and resize-handle hit information in a single query.
getEventAtPosition(x, y)
getResizeHandle(x, y)
calculateGuideLines(...)
Computes candidate guide lines for a drag target.
snapToGuideLines(newStartTime, duration): number | null
snapEdgeToGuideLines(edgeTime): number | null
Single-edge snapping for resize interactions.
canMoveEvent(...): boolean
Checks whether an event can move to a target position. The current implementation validates:
- whether the time range is legal
- whether the destination track would overlap another event
- whether any plugin rejects the move via
validate:event:move
showSplitLine(trackIndex, eventIndex, splitTime): void
hideSplitLine(): void
splitEvent(trackIndex, eventIndex, splitTime): boolean
Used to preview and execute event splitting.
Notes:
- The split point must leave both resulting events longer than
minEventDuration - A successful split reports through
onEventUpdatewithtype: "split"
State, highlight, and debugging
setReadOnly(readOnly: boolean): void
Entering read-only mode clears current selection, drag state, guide lines, and context-menu state.
isReadOnly(): boolean
highlightEvent(trackIndex, eventIndex): boolean
Highlights an event programmatically.
clearHighlight(): void
getHighlightedEvent(): { trackIndex: number; eventIndex: number } | null
highlightEvent()andclearHighlight()update state and rendering, but they do not currently triggeronEventHighlight. That callback mainly comes from user-driven selection in the interaction layer.