Methods
paprika-tween/sweet(options) → {Promise}
The function
sweet()
creates a tween animation that will run for the given duration, interpolating the
given properties from start to end by using an easing function.sweet()
returns a thenable object
which can be chained with the method then()
or awaited with the keyword await
to create animations.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object
|
|
Returns:
- Type:
-
Promise
- A Promise that is resolved with two arguments: a
sweetie()
function to continue with
animation, and the Sweetie instance which properties are interpolated.
Example
import { sweet } from 'paprika-tween';
const { sweetie, spice } = await sweet({
duration: 500,
from: { size: 0 },
to: { size: 10 }
render: ({ size }) => {
obj.style.borderWidth = `${size}px`;
}
});
await sweetie({
duration: 1000,
to: { size: 20 }
});
await sweetie({
to: { size: 1 }
});
await sweetie({
delay: 50,
to: { size: 100 }
});