Animator Class
Constructs animator objects
Example:
// create animator
var animator = new Animator({
interval: 1, // time between animation frames
duration: 400, // length of animation
onComplete: function(){},
onStep: function(){},
transition: Animator.Transition.easeInOut
});
animator.addSubject(function(state) { // state starts from 1.0 to 0.0
var self = this super;
self.alpha = (state*255).toInteger();
})
// play animator
animator.play();
Constructor
Animator
[options]
Parameters:
-
[options]
Object optional{Object} Options to construct animator object. The default options are:
Example:
// create animator
var animator = new Animator({
interval: 1, // time between animation frames
duration: 400, // length of animation
onComplete: function(){},
onStep: function(){},
transition: Animator.Transition.easeInOut
});
animator.addSubject(function(state) { // state starts from 1.0 to 0.0
var self = this super;
self.alpha = (state*255).toInteger();
})
// play animator
animator.play();
Item Index
Methods
- applyDefaults static
- clearSubjects
- jumpTo
- makeADSR static
- makeBounce static
- makeEaseIn static
- makeEaseOut static
- makeElastic static
- onTimerEvent
- play
- reverse
- seekFromTo
- seekTo
- setOptions
- stop
- toggle
Properties
Events
Methods
applyDefaults
defaults
prefs
Merge the properties of two objects
Parameters:
-
defaults
ObjectConfiguration object with animator defaults
-
prefs
ObjectCustom configuration object
clearSubjects
()
Remove all subjects
jumpTo
to
[propagate=true]
Animate from the current state to provided value
makeADSR
() Function static
Make an Attack Decay Sustain Release envelope that starts and finishes on the same level
Returns:
makeBounce
bounces
Make a transition function that, like a ball falling to floor, reaches the target and bounces back again
Parameters:
-
bounces
Integer
makeEaseIn
a
Make a transition function that gradually accelerates. pass a=1 for smooth gravitational acceleration, higher values for an exaggerated effect.
Parameters:
-
a
Integer
Returns:
makeElastic
bounces
Make a transition function that, like an object with momentum being attracted to a point, goes past the target then returns
Parameters:
-
bounces
Integer
onTimerEvent
()
Called once per frame to update the current state
play
()
Play animation
reverse
()
Reverse animation
seekFromTo
from
to
Animate from the current state to provided value
seekTo
to
Animate from the current state to provided value
Parameters:
-
to
FloatDefines end point
setOptions
options
Apply default options
Parameters:
-
options
ObjectConfiguration object ot be applied to the Animator default options
stop
()
Stop animation
toggle
()
Seek to the opposite of the current target
Properties
Events
onComplete
Call-back function. This function is called when application ends.
onStep
Call-back function. This function is called when animation frame is changed.