Interpolation helper for animations
Implements the Promise API with an additional "cancel" method.
The promise is resolved with true when the animation is completed and false if the animation is cancelled.
| Name | Type | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
|
Example
const anim = new Animation({
properties: {
width: {start: 100, end: 200}
},
duration: 5000,
onTick: (properties) => element.style.width = `${properties.width}px`;
});
anim.then((completed) => ...);
anim.cancel()
Methods
-
Cancels the animation
-
-
Promise chaining
-
Name Type Description onFulfilledfunction optional Called when the animation is complete (true) or cancelled (false)
Returns:
Type Description Promise
Type Definitions
-
Function called for each animation frame with computed properties
-
Name Type Description propertiesObject.<string, number> current values
progressfloat 0 to 1