Class: Animation

PSV.utils.Animation

new PSV.utils.Animation (options)

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
Name Type Default Description
properties Object.<string, Object>
properties[].start number
properties[].end number
duration number
delay number 0 optional
easing string 'linear' optional
onTick PSV.utils.Animation.OnTick

called on each frame

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

cancel ()

Cancels the animation

then (onFulfilled)Promise

Promise chaining

Name Type Description
onFulfilled function optional

Called when the animation is complete (true) or cancelled (false)

Returns:
Type Description
Promise

Type Definitions

PSV.utils.Animation.OnTick (properties, progress)

Function called for each animation frame with computed properties

Name Type Description
properties Object.<string, number>

current values

progress float

0 to 1