Tween Duration
- This method gets or sets the animation’s duration — the total length of time (in seconds) the animation runs, excluding repeats or repeatDelays.
duration()
duration(value:Number): [Number | self]
This method gets or sets the animation’s duration — the total length of time (in seconds) the animation runs, excluding repeats or repeatDelays.
Parameters
-
value (Number, default = NaN)
-
If omitted, the current duration is returned (getter).
-
If defined, it sets the duration (setter) and returns the animation instance, enabling method chaining.
-
Returns
-
[Number | self]
-
Returns the current duration if no value is passed.
-
Returns the animation instance when a new duration is set.
-
Details
The duration defines how long a single playthrough of the animation lasts.
It doesn’t include any repeats or repeatDelays.For example, if a tween has:
-
a duration of
2seconds, and -
a repeat count of
3,
then its totalDuration will be
8seconds
(2 seconds × (1 original + 3 repeats)= 8).This method acts as both a getter and setter.
Omitting the parameter retrieves the current duration, while providing one sets it and allows for chaining.-
Example
var currentDuration = myAnimation.duration();
//gets current durationmyAnimation.duration(4);
//sets duration