Skip to content

Latest commit

 

History

History
266 lines (194 loc) · 9.69 KB

File metadata and controls

266 lines (194 loc) · 9.69 KB

Classes

AnimationEventEmitter

Base class for creating other animations. Each custom animation must extends from this class.

Constants

EASING : Object

Dictionary of all available easings for Animation. You can use it as easing option in all of the animations.

Animation ⇐ EventEmitter

Base class for creating other animations. Each custom animation must extends from this class.

Kind: global class
Extends: EventEmitter
Since: 1.0.0

new Animation([options])

Creates animation class that has animate method for animating properties in the shape.

Param Type Default Description
[options] Object Options object
[options.duration] Number 1000 Duration of the animation in ms
[options.easing] String 'outQuad' Easing name from EASING dictionary

Example

Animation.create({
  duration: 5000,
  easing: 'outElastic'
});

animation.get(path) ⇒ *

Get option value.

Kind: instance method of Animation

Param Type Description
path String Path can be set with dot-notation

Example

animation.get('my.value.from.object');

animation.set(path, value) ⇒ Animation

Set new option value.

Kind: instance method of Animation

Param Type Description
path String Path can be set with dot-notation
value * Value that need to be written to the options object

Example

animation.set('my.value.from.object', 'value');

animation.getDuration() ⇒ Number

Get animation duration in ms.

Kind: instance method of Animation

animation.setDuration([duration]) ⇒ Animation

Set new animation duration in ms.

Kind: instance method of Animation

Param Type Default Description
[duration] Number 1000 Duration of the animation in ms

animation.getEasing() ⇒ String

Get easing name.

Kind: instance method of Animation

animation.setEasing([easing]) ⇒ Animation

Set new easing for animation.

Kind: instance method of Animation

Param Type Default Description
[easing] String 'outQuad' Easing name from EASING dictionary

animation.delay(ms) ⇒ Promise

Makes delay before executing function.

Kind: instance method of Animation
Returns: Promise - Returns Promise that fulfills when delay is over

Param Type Description
ms Number Timeout in ms

animation.onTick(shape, property, value) ⇒ Animation

Triggers each time when animation ticks.

Kind: instance method of Animation

Param Type Description
shape Shape Shape instance
property String Property name of the shape
value Number New value of the specified property

animation.onEasing(easing, time, startValue, byValue, duration) ⇒ Number

Triggers each time when easing calculates new value in time.

Kind: instance method of Animation

Param Type Description
easing String Easing name
time Number Current time
startValue Number Start value
byValue Number Change in value
duration Number Duration

animation.animate(shape) ⇒ Promise

Main method that calls every time when shape needs to be animated. This method must return Promise that fulfills with shape instance that has been animated.

Kind: instance abstract method of Animation
Returns: Promise - Returns Promise that fulfills with shape instance when animation is done
Fulfil: Shape If method is implemented, it should fulfil the Promise with a Shape instance
Reject: Error If method is not overridden rejects the Promise with an Error

Param Type Description
shape Shape Shape instance that need to be animated

animation.animateProperty(options) ⇒ Promise

Helper method that animates property in object. On each animation tick it calls onTick method with shape, property and newValue arguments. Also, you can subscribe in your childes to tick event and do your own stuff.

Kind: instance method of Animation
Returns: Promise - Returns Promise, that fulfills with shape instance which has been animated
Fulfil: Shape When animation is done, fulfils with Shape instance

Param Type Description
options Object Options object
options.shape Shape Shape where property is need to be animated
options.property String Property name that need to be animated
options.startValue Number Start value for animation
options.endValue Number End value for animation
[options.byValue] Number Step value for easing, by default it calculates automatically
[options.duration] Number Duration of the animation in ms, by default it takes from Animation options
[options.easing] String Easing that need to apply to animation, by default it takes from Animation options

animation.toObject() ⇒ Object

Serializes animation to the object representation.

Kind: instance method of Animation

animation.toJSON() ⇒ JSON

Serializes animation to the JSON representation.

Kind: instance method of Animation

Animation.create(args) ⇒ Animation

Static wrapper around new Animation().

Kind: static method of Animation

Param
args

Animation.fromObject(obj) ⇒ Animation

Creates animation instance from the Object representation.

Kind: static method of Animation
Throws:

  • Error If object is not a representation of Animation
Param Type Description
obj Object Object from toObject method

Animation.fromJSON(json) ⇒ Animation

Creates animation instance from the JSON representation.

Kind: static method of Animation

Param Type Description
json JSON JSON from toJSON method

EASING : Object

Dictionary of all available easings for Animation. You can use it as easing option in all of the animations.

Kind: global constant