flow
import
{
...
}
from
"@motion-canvas/core/lib/flow"
;
Utilities for controlling the flow and timing of an animation.
Interfaces
-
EveryCallback -
EveryTimer -
LoopCallback
Functions
all
public
all
...
tasks
:
ThreadGenerator
[]
:
ThreadGenerator
Run all tasks concurrently and wait for all of them to finish.
Examples
Parameters
-
... tasks : ThreadGenerator []A list of tasks to run.
any
public
any
...
tasks
:
ThreadGenerator
[]
:
ThreadGenerator
Run all tasks concurrently and wait for any of them to finish.
Examples
Parameters
-
... tasks : ThreadGenerator []A list of tasks to run.
chain
public
chain
...
tasks
:
ThreadGenerator
Callback
[]
:
ThreadGenerator
Run tasks one after another.
Examples
Parameters
-
... tasks : ThreadGenerator Callback []A list of tasks to run.
delay
public
delay
time
:
number
task
:
ThreadGenerator
Callback
:
ThreadGenerator
Run the given generator or callback after a specific amount of time.
Examples
Parameters
-
time : numberThe delay in seconds
-
task : ThreadGenerator CallbackThe task or callback to run after the delay.
every
Call the given callback every N seconds.
Examples
Parameters
-
interval : numberThe interval between subsequent calls.
-
callback : EveryCallbackThe callback to be called.
loop
public
loop
iterations
:
number
factory
:
LoopCallback
:
ThreadGenerator
Run the given generator N times.
Each time iteration waits until the previous one is completed.
Examples
Parameters
-
iterations : numberThe number of iterations.
-
factory : LoopCallbackA function creating the generator to run. Because generatorscan't be reset, a new generator is created on each iteration.
noop
public
noop
():
ThreadGenerator
Do nothing.
run
public
run
runner
:
public
()
:
ThreadGenerator
public
run
name
:
string
runner
:
public
()
:
ThreadGenerator
Turn the given generator function into a threadable generator.
Examples
Parameters
-
runner : public ()A generator function or a factory that creates the generator.
sequence
public
sequence
delay
:
number
...
tasks
:
ThreadGenerator
[]
:
ThreadGenerator
Start all tasks one after another with a constant delay between.
The function doesn't wait until the previous task in the sequence hasfinished. Once the delay has passed, the next task will start even ifthe previous is still running.
Examples
Parameters
-
delay : numberThe delay between each of the tasks.
-
... tasks : ThreadGenerator []A list of tasks to be run in a sequence.
waitFor
public
waitFor
seconds
:
number
=
0
after
?:
ThreadGenerator
:
ThreadGenerator
Wait for the given amount of time.
Examples
Parameters
-
seconds : number = 0The relative time in seconds.
-
after ?: ThreadGeneratorAn optional task to be run after the function completes.
waitUntil
public
waitUntil
event
:
string
after
?:
ThreadGenerator
:
ThreadGenerator
Wait until the given time event.
Time events are displayed on the timeline and can be edited to adjust thedelay. By default, an event happens immediately - without any delay.
Examples
Parameters
-
event : stringThe name of the time event.
-
after ?: ThreadGeneratorAn optional task to be run after the function completes.