Animation

new Animation(options)

Parameters:
NameTypeDescription
optionsobject

Animation options

Properties
NameTypeAttributesDescription
durationnumber<optional>

Duration of the animation in seconds

curvefunction<optional>

Curve function that takes a time between [0, 1] and returns a value between [0, 1]

delaynumber<optional>

The amount of delay before the animation starts

onstopfunction<optional>

Function that is fired when the animation is forcibly stopped

onendfunction<optional>

Function fired when the function completes successfully

ontickfunction<optional>

Function fired when the animation ticks every frame. Takes a number between [0, 1] for the animation's progress.

WorldWorld<optional>

World the animation should be bound to. If specified, the animation will use the world's timescale. If not, it will run independent of any world's timescale.

Members

ease

A variety of built in ease functions to use for animations
See easings.net for animation types. All animation types except elastic and bounce are implemented.

Properties
NameTypeDescription
ease.linearfunction
ease.in.sinefunction
ease.in.quadraticfunction
ease.in.cubicfunction
ease.in.quarticfunction
ease.in.quinticfunction
ease.in.exponentialfunction
ease.in.circularfunction
ease.in.backfunction
ease.out.sinefunction
ease.out.quadraticfunction
ease.out.cubicfunction
ease.out.quarticfunction
ease.out.quinticfunction
ease.out.exponentialfunction
ease.out.circularfunction
ease.out.backfunction
ease.inOut.sinefunction
ease.inOut.quadraticfunction
ease.inOut.cubicfunction
ease.inOut.quarticfunction
ease.inOut.quinticfunction
ease.inOut.exponentialfunction
ease.inOut.circularfunction
ease.inOut.backfunction
Example
Animation.ease.in.cubic // access the cubic ease in function

Methods

isRunning() → {boolean}

Gets if the animation is currently running. Running includes any delay that the animation may have.

Returns:

If the animation is running

Type: 
boolean

run() → {Promise}

Starts the animation

Returns:

Resolves when the animation completes. Resolves to true if the animation finished, false if it was stopped before it finished.

Type: 
Promise

stop()

Stops the animation before it finishes. Triggers onstop and resolves promises to false.