Core.Transitionable Class
samsara/core/Transitionable.js:21
A way to transition numeric values and arrays of numbers between start and end states. Transitions are given an easing curve and a duration. Non-numeric values are ignored.
Constructor
Core.Transitionable
-
value
Example:
var transitionable = new Transitionable(0);
transitionable.set(100, {duration : 1000, curve : 'easeIn'});
transitionable.on('start', function(value){
console.log(value); // 0
});
transitionable.on('update', function(value){
console.log(value); // numbers between 0 and 100
});
transitionable.on('end', function(value){
console.log(value); // 100
});
Item Index
Methods
delay
-
callback
-
duration
Postpone a transition, and fire it by providing it in the callback parameter.
filter
-
filterFn
Parameters:
-
filterFn
FunctionFunction to filter event payload
halt
()
Ends the transition in place.
loop
-
transitions
Loop indefinitely between values with provided transitions array.
Parameters:
-
transitions
ArrayArray of transitions
Example:
transitionable.loop([ [0, {curve : 'easeOut', duration : 500}], [1, {curve : 'spring', period : 100, damping : 0.5}] ]);
map
-
mapperFn
Parameters:
-
mapperFn
FunctionFunction to map event payload
pluck
-
key
register
-
name
-
constructor
Constructor method. A way of registering other engines that can interpolate between start and end values. For instance, a physics engine.
reset
-
value
-
[velocity]
Sets the value and velocity of the transition without firing any events.
set
-
value
-
[transition]
-
[callback]
Define a new end value that will be transitioned towards with the prescribed transition. An optional callback can fire when the transition completes.
setMany
-
transitions
-
[callback]
Combine multiple transitions to be executed sequentially. Pass an optional callback to fire on completion. Provide the transitions as an array of transition definition pairs: [value, method]
Example:
transitionable.setMany([ [0, {curve : 'easeOut', duration : 500}], [1, {curve : 'spring', period : 100, damping : 0.5}] ]);
split
-
splitterFn
Parameters:
-
splitterFn
FunctionSplitter function
unregister
-
name
Constructor method. Unregister an interpolating engine.
Undoes work of register
.
Parameters:
-
name
StringIdentifier for the engine