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.
iterate
-
values
-
transitions
-
[callback]
Iterate through the provided values with the provided transitions. Firing an optional callback when the series of transitions completes. One transition may be provided as opposed to an array when you want all the transitions to behave the same way.
loop
-
transitions
Loop indefinitely between values with provided transitions array.
Parameters:
-
transitions
ArrayArray of transitions
Example:
transitionable.loop([ {value : 0, transition : {curve : 'easeOut', duration : 500}}, {value : 1, transition : {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
Combine multiple transitions to be executed sequentially. Provide the transitions as an array of transition definitions.
Parameters:
-
transitions
ArrayArray of transitions
Example:
transitionable.setMany([ {value : 0, transition : {curve : 'easeOut', duration : 500}}, {value : 1, transition : {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