Timeline API 总览
Timeline 是时间轴运行时的核心类,负责把数据、交互、渲染调度和插件系统组织在一起。
构造函数
参数
canvasId: 目标<canvas>元素的idoptions: 构造参数,类型为TimelineOptions
公开属性
config: 归一化后的运行时配置callbacks: 当前回调集合state: 当前运行时状态
如果你直接修改了
timeline.config或timeline.state,请配合调用notifyChange();如果已有对应方法,优先使用公开方法而不是直接改内部状态。
API 目录
数据管理
loadDataaddEventupdateEventupdateEventDatadeleteEventaddTrack/removeTrackautoRemoveEmptyLastTracksetEndTime/getEndTimebeginIndexBatch/endIndexBatchinvalidateIndexTrack/invalidateIndexAll
视图、交互与状态
setZoomLevel/zoom/getZoomLevelsetTimeIndicator/setTimeIndicatorDuringDragsetCanvasSize/adjustCanvasSize/drawmarkDirty/notifyChangebeginChangeBatch/endChangeBatchgetInteractionTarget/getEventAtPosition/getResizeHandlecalculateGuideLines/snapToGuideLines/snapEdgeToGuideLinescanMoveEventshowSplitLine/hideSplitLine/splitEventsetReadOnly/isReadOnlyhighlightEvent/clearHighlight/getHighlightedEventsetDebug/setEnableTimeIndicatorsetStatus/getStatus
插件管理
usePluginremovePluginsetThemegetLoadedPluginsisPluginLoaded
事件回调
onEventAddonEventUpdateonEventDeleteonEventMoveonEventClickonEventHighlightonTimeIndicatorHighlightonStatusChange
类型定义
TimelineOptionsTimelineConfigTimelineEventInteractionTargetLoadDataFormat
销毁实例
destroy() 会移除画布监听器并清理交互态。页面卸载或组件销毁时应调用它。