Constructor
new Spice(options)
Creates a new Spice instance with the given options.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
|
Example
import { Spice } from 'paprika-tween';
import { Cubic } from 'paprika-tween/easing';
const spice = new Spice({
duration: 45,
delay: 2,
easing: Cubic.InOut,
from: { size: 10 },
to: { size: 520 },
render: ({ size }) => {
console.log(size);
},
onEnd: ({ size }) => console.log(props)
});
spice.start(0);
spice.frame(15);
Classes
Methods
dispose()
Removes the interpolatable properties of the instance and its callback functions, making the instance eligible
for the garbage collector.
frame(timeopt)
Moves the interpolation of the properties of the spice 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 { Spice } from 'paprika-tween';
const spice = new Spice({
duration: 10,
from: { width: 100 },
to: { width: 550 },
render: (props) => { ... }
});
spice.start(0);
spice.frame(2);
start(timeopt)
Sets the starting time of the interpolation 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 { Spice } from 'paprika-tween';
const spice = new Spice({ ... });
spice.start(5);
update(options) → {Spice}
Modifies the properties of the spice with the given object.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object
|
See Spice constructor for the available properties of the options object.
|
Returns:
- Type:
-
Spice