Track
Acts as a placeholder to organize the vertical layout of the visualization and the horizontal alignement to an abscissa that correspond to a common time reference. It basically offer a view on the overall timeline.
Tracks are inserted into a given DOM element, allowing to create DAW like
representations. Each Track
instance can host multiple Layer
instances.
A track must be added to a timeline before being updated.
A timeline with 3 tracks:
0 6 16
+- - - - - - - - -+-------------------------------+- - - - - - -
| |x track 1 xxxxxxxxxxxxxxxxxxxxx|
+- - - - - - - - -+-------------------------------+- - - - - - -
| |x track 2 xxxxxxxxxxxxxxxxxxxxx|
+- - - - - - - - -+-------------------------------+- - - - - - -
| |x track 3 xxxxxxxxxxxxxxxxxxxxx|
+- - - - - - - - ---------------------------------+- - - - - - -
+----------------->
timeline.timeContext.timeToPixel(timeline.timeContext.offset)
<------------------------------->
timeline's tracks defaults to 1000px
with a default pixelsPerSecond of 100px/s.
and a default `stretchRatio = 1`
track1 shows 10 seconds of the timeline
Track DOM structure
<svg width="${visibleWidth}">
<!-- background -->
<rect><rect>
<!-- main view -->
<g class="offset" transform="translate(${offset}, 0)">
<g class="layout">
<!-- layers -->
</g>
</g>
<g class="interactions"><!-- for feedback --></g>
</svg>
Constructor Summary
Public Constructor | ||
public |
constructor($el: DOMElement, height: Number) |
Member Summary
Public Members | ||
public |
|
|
public |
The DOM element in which the track is created. |
|
public |
A placeholder to add shapes for interactions feedback. |
|
public |
|
|
public |
|
|
public |
|
|
public get |
Returns the height of the track. |
|
public set |
Sets the height of the track. |
|
public |
An array of all the layers belonging to the track. |
|
public |
The context used to maintain the DOM structure of the track. |
Method Summary
Public Methods | ||
public |
Iterates through the added layers. |
|
public |
Adds a layer to the track. |
|
public |
destroy() Destroy the track. |
|
public |
hasElement($el: Element): bool Tests if a given element belongs to the track. |
|
public |
Removes a layer from the track. |
|
public |
render() Render all the layers added to the track. |
|
public |
Updates the track DOM structure and updates the layers. |
|
public |
Updates the track DOM structure. |
|
public |
updateLayers(layers: Array<Layer>) Updates the layers. |
Public Constructors
Public Members
public set height: Number source
Sets the height of the track.
TODO:
- propagate to layers, keeping ratio? could be handy for vertical resize. This is why a set/get is implemented here.
public renderingContext: TimelineTimeContext source
The context used to maintain the DOM structure of the track.
Public Methods
public add(layer: Layer) source
Adds a layer to the track.
Params:
Name | Type | Attribute | Description |
layer | Layer | the layer to add to the track. |
public destroy() source
Destroy the track. The layers from this track can still be reused elsewhere.
public hasElement($el: Element): bool source
Tests if a given element belongs to the track.
Params:
Name | Type | Attribute | Description |
$el | Element |
Return:
bool |
public remove(layer: Layer) source
Removes a layer from the track. The layer can be reused elsewhere.
Params:
Name | Type | Attribute | Description |
layer | Layer | the layer to remove from the track. |