Class: Tween<T>
Tweening.Tween
A Tween represents a series of actions that can be applied to a target object to create animations or sequences of events.
Type parameters
| Name | Type | Description |
|---|---|---|
T | any | The type of the target object. |
Constructors
constructor
• new Tween<T>(target)
Type parameters
| Name | Type |
|---|---|
T | any |
Parameters
| Name | Type | Description |
|---|---|---|
target | T | The object to apply the tween to. |
Defined in
Properties
id
• id: string
Unique identifier. If specified, the old tween with the same id will be stopped.
Defined in
tags
• tags: string[] = []
Tags used for filtering and management.
Defined in
target
• target: T
The object to apply the tween to.
Defined in
Methods
by
▸ by(time, action, config?): Tween<T>
Define a relative motion from the current state.
Parameters
| Name | Type | Description |
|---|---|---|
time | number | The duration of the motion in milliseconds. |
action | Motion<T> | The motion configuration. |
config? | MotionConfig<T> | Additional motion configuration options. |
Returns
Tween<T>
The updated Tween instance.
Defined in
call
▸ call(callback): Tween<T>
Add a callback action to the Tween.
Parameters
| Name | Type | Description |
|---|---|---|
callback | () => void | The callback function to execute. |
Returns
Tween<T>
The updated Tween instance.
Defined in
chain
▸ chain(tween): Tween<T>
Chain actions from another Tween to this Tween.
Parameters
| Name | Type | Description |
|---|---|---|
tween | Tween<T> | The Tween containing actions to chain. |
Returns
Tween<T>
The updated Tween instance.
Defined in
clone
▸ clone(): Tween<T>
Clone the Tween instance.
Returns
Tween<T>
A new Tween instance with the same configuration.
Defined in
delay
▸ delay(time): Tween<T>
Add a delay before executing the next action.
Parameters
| Name | Type | Description |
|---|---|---|
time | number | The duration of the delay in milliseconds. |
Returns
Tween<T>
The updated Tween instance.
Defined in
parallel
▸ parallel(...tweens): Tween<T>
Run multiple Tweens in parallel.
Parameters
| Name | Type | Description |
|---|---|---|
...tweens | Tween<T>[] | The Tweens to run in parallel. |
Returns
Tween<T>
The updated Tween instance.
Defined in
repeat
▸ repeat(times?): Tween<T>
Repeat the last action for a specific number of times.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
times | number | 1 | The number of times to repeat the action. |
Returns
Tween<T>
The updated Tween instance.
Defined in
repeatForever
▸ repeatForever(): Tween<T>
Repeat the last action indefinitely.
Returns
Tween<T>
The updated Tween instance.
Defined in
sequence
▸ sequence(...tweens): Tween<T>
Run multiple Tweens in sequence.
Parameters
| Name | Type | Description |
|---|---|---|
...tweens | Tween<T>[] | The Tweens to run in sequence. |
Returns
Tween<T>
The updated Tween instance.
Defined in
set
▸ set(action): Tween<T>
Define a movement from the current state to a new state instantaneously.
Parameters
| Name | Type | Description |
|---|---|---|
action | SetMotion<T> | The motion configuration. |
Returns
Tween<T>
The updated Tween instance.
Defined in
setId
▸ setId(id): Tween<T>
Set a unique identifier for the Tween. If specified, stops the old tween with the same id.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The identifier to assign to the Tween. |
Returns
Tween<T>
The updated Tween instance.
Defined in
setTags
▸ setTags(...tags): Tween<T>
Set tags for the Tween, which can be used for filtering and management.
Parameters
| Name | Type | Description |
|---|---|---|
...tags | string[] | Tags to associate with the Tween. |
Returns
Tween<T>
The updated Tween instance.
Defined in
setTarget
▸ setTarget(target): Tween<T>
Set the target object for the Tween.
Parameters
| Name | Type | Description |
|---|---|---|
target | T | The object to apply the tween to. |
Returns
Tween<T>
The updated Tween instance.
Defined in
start
▸ start(): RunningTween<T>
Start the Tween and create a RunningTween instance.
Returns
RunningTween<T>
A RunningTween instance that controls the execution of the Tween.
Defined in
then
▸ then(tween): Tween<T>
Chain another Tween to execute after this Tween.
Parameters
| Name | Type | Description |
|---|---|---|
tween | Tween<T> | The Tween to chain. |
Returns
Tween<T>
The updated Tween instance.
Defined in
to
▸ to(time, action, config?): Tween<T>
Define a motion from the current state to a new state over a specified time.
Parameters
| Name | Type | Description |
|---|---|---|
time | number | The duration of the motion in milliseconds. |
action | Motion<T> | The motion configuration. |
config? | MotionConfig<T> | Additional motion configuration options. |
Returns
Tween<T>
The updated Tween instance.
Defined in
yoyo
▸ yoyo(times?): Tween<T>
Apply a yoyo effect to the last action, making it reverse its motion, for a specific number of times.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
times | number | 1 | The number of times to yoyo the last action. |
Returns
Tween<T>
The updated Tween instance.
Defined in
yoyoForever
▸ yoyoForever(): Tween<T>
Apply a yoyo effect to the last action, making it reverse its motion, indefinitely.
Returns
Tween<T>
The updated Tween instance.