API Documentation for: 0.4.1
Show:

Timeline Class

Defined in: Timeline:34
Module: TweenJS

The Timeline class synchronizes multiple tweens and allows them to be controlled as a group. Please note that if a timeline is looping, the tweens on it may appear to loop even if the "loop" property of the tween is false.

Constructor

Timeline

(
  • tweens
  • labels
  • props
)

Defined in Timeline:34

Parameters:

  • tweens Object

    An array of Tweens to add to this timeline. See addTween for more info.

  • labels #crossLink "Timeline/setLabels"

    An object defining labels for using gotoAndPlay/Stop. See }{{/crossLink}} for details.

  • props Loop:true

    The configuration properties to apply to this tween instance (ex. ). All properties default to false. Supported props are:

    • loop: sets the loop property on this tween.
    • useTicks: uses ticks for all durations instead of milliseconds.
    • ignoreGlobalPause: sets the ignoreGlobalPause property on this tween.
    • paused: indicates whether to start the tween paused.
    • position: indicates the initial position for this timeline.
    • onChanged: specifies an onChange handler for this timeline.

Methods

_goto

() protected

Defined in _goto:332

addLabel

(
  • label
  • position
)

Defined in addLabel:206

Adds a label that can be used with gotoAndPlay/Stop.

Parameters:

  • label Object

    The label name.

  • position Object

    The position this label represents.

addLabel

(
  • o
)

Defined in addLabel:216

Defines labels for use with gotoAndPlay/Stop. Overwrites any previously set labels.

Parameters:

  • o LabelName:time

    An object defining labels for using gotoAndPlay/Stop in the form where time is in ms (or ticks if useTicks is true).

addTween

(
  • tween
)

Defined in addTween:162

Adds one or more tweens (or timelines) to this timeline. The tweens will be paused (to remove them from the normal ticking system) and managed by this timeline. Adding a tween to multiple timelines will result in unexpected behaviour.

Parameters:

  • tween Object

    The tween(s) to add. Accepts multiple arguments.

Returns:

Tween The first tween that was passed in.

clone

() protected

Defined in clone:323

gotoAndPlay

(
  • positionOrLabel
)

Defined in gotoAndPlay:225

Unpauses this timeline and jumps to the specified position or label.

Parameters:

  • positionOrLabel Object

    The position in milliseconds (or ticks if useTicks is true) or label to jump to.

gotoAndStop

(
  • positionOrLabel
)

Defined in gotoAndStop:235

Pauses this timeline and jumps to the specified position or label.

Parameters:

  • positionOrLabel Object

    The position in milliseconds (or ticks if useTicks is true) or label to jump to.

initialize

() protected

Defined in initialize:141

Initialization method.

removeTween

(
  • tween
)

Defined in removeTween:185

Removes one or more tweens from this timeline.

Parameters:

  • tween Object

    The tween(s) to remove. Accepts multiple arguments.

Returns:

Boolean Returns true if all of the tweens were successfully removed.

resolve

(
  • positionOrLabel
)

Defined in resolve:302

If a numeric position is passed, it is returned unchanged. If a string is passed, the position of the corresponding frame label will be returned, or null if a matching label is not defined.

Parameters:

  • positionOrLabel Object

    A numeric position value or label string.

setPaused

(
  • value
)

Defined in setPaused:268

Pauses or plays this timeline.

Parameters:

  • value Object

    Indicates whether the tween should be paused (true) or played (false).

setPosition

(
  • value
  • actionsMode
)

Defined in setPosition:245

Advances the timeline to the specified position.

Parameters:

  • value Object

    The position to seek to in milliseconds (or ticks if useTicks is true).

  • actionsMode Object

    Optional parameter specifying how actions are handled. See Tween.setPosition for more details.

Returns:

Boolean Returns true if the timeline is complete (ie. the full timeline has run & loop is false).

tick

(
  • delta
)

Defined in tick:292

Advances this timeline by the specified amount of time in milliseconds (or ticks if useTicks is true). This is normally called automatically by the Tween engine (via Tween.tick), but is exposed for advanced uses.

Parameters:

  • delta Object

    The time to advance in milliseconds (or ticks if useTicks is true).

toString

() String

Defined in toString:314

Returns a string representation of this object.

Returns:

String: a string representation of the instance.

updateDuration

()

Defined in updateDuration:278

Recalculates the duration of the timeline. The duration is automatically updated when tweens are added or removed, but this method is useful if you modify a tween after it was added to the timeline.

Properties

_labels

ArrayString protected

Defined in _labels:112

_paused

Boolean protected

Defined in _paused:98

_prevPos

Number protected

Defined in _prevPos:126

_prevPosition

Number protected

Defined in _prevPosition:119

_tweens

ArrayTween protected

Defined in _tweens:105

_useTicks

Boolean protected

Defined in _useTicks:133

duration

Number

Defined in duration:66

Read-only property specifying the total duration of this timeline in milliseconds (or ticks if useTicks is true). This value is usually automatically updated as you modify the timeline. See updateDuration for more information.

ignoreGlobalPause

Boolean

Causes this timeline to continue playing when a global pause is active.

loop

Boolean

Defined in loop:74

If true, the timeline will loop when it reaches the end. Can be set via the props param.

onChange

Function

Defined in onChange:81

Called, with a single parameter referencing this timeline instance, whenever the timeline's position changes.

position

Object

Defined in position:88

Read-only. The current normalized position of the timeline. This will always be a value between 0 and duration. Changing this property directly will have no effect.