Constructor
new Mixer()
Creates a new Mixer instance.
Example
import { Mixer, Spice } from 'paprika-tween';
const spice = new Spice({
duration: 1000,
from: { x: 0, y: 42 },
to: { x: 200, y: 120 },
render: (props, interpolation) => {
console.log(props.x, props.y, interpolation);
}
});
const mixer = new Mixer();
mixer.add(spice)
.start();
function loop(timestamp) {
mixer.frame(timestamp);
requestAnimationFrame(loop);
}
requestAnimationFrame(loop);
Classes
Methods
add(…rest) → {Mixer}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
rest |
Spice
|
Recipe
|
<repeatable> |
Instances of Paprika animatable objects. |
Example
import { Mixer, Spice } from 'paprika-tween';
const spice1 = new Spice({ ... });
const spice2 = new Spice({ ... });
const mixer = new Mixer();
mixer.add(spice1, spice2);
dispose()
Stops all animations and clears the stack of animatable objects.
frame(timeopt)
Moves the interpolation of the properties of the animatable objects in the mixer by the given time, which is
relative to the starting time.
If
If
time
is not provided, the timestamp from
performance.now()
will be used instead.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
time |
DOMHighResTimeStamp
|
number
|
<optional> |
The amount of time to interpolate since the animations started. |
Example
import { Mixer, Spice } from 'paprika-tween';
const spice = new Spice({
duration: 10,
from: { width: 100 },
to: { width: 550 },
render: (props) => { ... }
});
const mixer = new Mixer(0);
mixer.add(spice)
.start();
mixer.frame(1);
start(timeopt) → {Mixer}
Starts all the animations in the mixer by setting the starting time of each animatable objects at the given
If
time
argument.If
time
is not provided, the timestamp from
performance.now()
will be used instead.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
time |
DOMHighResTimeStamp
|
number
|
<optional> |
The initial number from where to start the animation. |
Example
import { Mixer } from 'paprika-tween';
const mixer = new Mixer();
mixer.start(0);