@twick/timeline / Exports / Track
Class: Track
Table of contents
Constructors
Properties
Methods
- addElement
- addElementViaFriend
- createFriend
- getElementById
- getElements
- getId
- getName
- getTrackDuration
- getType
- removeElement
- removeElementViaFriend
- serialize
- updateElement
- updateElementViaFriend
- validateAllElements
- validateElement
- fromJSON
Constructors
constructor
• new Track(name, id?): Track
Parameters
| Name | Type |
|---|---|
name | string |
id? | string |
Returns
Defined in
packages/timeline/src/core/track/track.ts:19
Properties
elements
• Private elements: TrackElement[]
Defined in
packages/timeline/src/core/track/track.ts:16
id
• Private id: string
Defined in
packages/timeline/src/core/track/track.ts:13
name
• Private name: string
Defined in
packages/timeline/src/core/track/track.ts:14
type
• Private type: string
Defined in
packages/timeline/src/core/track/track.ts:15
validator
• Private validator: ElementValidator
Defined in
packages/timeline/src/core/track/track.ts:17
Methods
addElement
▸ addElement(element, skipValidation?): boolean
Adds an element to the track with validation
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
element | TrackElement | undefined | The element to add |
skipValidation | boolean | false | If true, skips validation (use with caution) |
Returns
boolean
true if element was added successfully, throws ValidationError if validation fails
Defined in
packages/timeline/src/core/track/track.ts:103
addElementViaFriend
▸ addElementViaFriend(element, skipValidation?): boolean
Friend method to add element (called by TrackFriend)
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
element | TrackElement | undefined | The element to add |
skipValidation | boolean | false | If true, skips validation |
Returns
boolean
true if element was added successfully
Defined in
packages/timeline/src/core/track/track.ts:42
createFriend
▸ createFriend(): TrackFriend
Create a friend instance for explicit access to protected methods This implements the Friend Class Pattern
Returns
TrackFriend
TrackFriend instance
Defined in
packages/timeline/src/core/track/track.ts:32
getElementById
▸ getElementById(id): undefined | Readonly<TrackElement>
Parameters
| Name | Type |
|---|---|
id | string |
Returns
undefined | Readonly<TrackElement>
Defined in
packages/timeline/src/core/track/track.ts:163
getElements
▸ getElements(): readonly TrackElement[]
Returns
readonly TrackElement[]
Defined in
packages/timeline/src/core/track/track.ts:78
getId
▸ getId(): string
Returns
string
Defined in
packages/timeline/src/core/track/track.ts:66
getName
▸ getName(): string
Returns
string
Defined in
packages/timeline/src/core/track/track.ts:70
getTrackDuration
▸ getTrackDuration(): number
Returns
number
Defined in
packages/timeline/src/core/track/track.ts:91
getType
▸ getType(): string
Returns
string
Defined in
packages/timeline/src/core/track/track.ts:74
removeElement
▸ removeElement(element): void
Parameters
| Name | Type |
|---|---|
element | TrackElement |
Returns
void
Defined in
packages/timeline/src/core/track/track.ts:129
removeElementViaFriend
▸ removeElementViaFriend(element): void
Friend method to remove element (called by TrackFriend)
Parameters
| Name | Type | Description |
|---|---|---|
element | TrackElement | The element to remove |
Returns
void
Defined in
packages/timeline/src/core/track/track.ts:53
serialize
▸ serialize(): TrackJSON
Returns
Defined in
packages/timeline/src/core/track/track.ts:210
updateElement
▸ updateElement(element): boolean
Updates an element in the track with validation
Parameters
| Name | Type | Description |
|---|---|---|
element | TrackElement | The element to update |
Returns
boolean
true if element was updated successfully, throws ValidationError if validation fails
Defined in
packages/timeline/src/core/track/track.ts:141
updateElementViaFriend
▸ updateElementViaFriend(element): boolean
Friend method to update element (called by TrackFriend)
Parameters
| Name | Type | Description |
|---|---|---|
element | TrackElement | The element to update |
Returns
boolean
true if element was updated successfully
Defined in
packages/timeline/src/core/track/track.ts:62
validateAllElements
▸ validateAllElements(): Object
Validates all elements in the track and returns combined result and per-element status
Returns
Object
Object with overall isValid and array of per-element validation results
| Name | Type |
|---|---|
isValid | boolean |
results | { element: TrackElement ; errors?: string[] ; isValid: boolean ; warnings?: string[] }[] |
Defined in
packages/timeline/src/core/track/track.ts:173
validateElement
▸ validateElement(element): boolean
Validates an element
Parameters
| Name | Type | Description |
|---|---|---|
element | TrackElement | The element to validate |
Returns
boolean
true if valid, throws ValidationError if invalid
Defined in
packages/timeline/src/core/track/track.ts:87
fromJSON
▸ fromJSON(json): Track
Parameters
| Name | Type |
|---|---|
json | any |