new EaseMachine(fc, ms [, startValues] [, endValues])
A simple device to make ease functions easy to use. Requests a cubic function that takes the form function (t, b, c, d) t = current time b = starting value c = change in value d = duration
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
fc |
function | The cubic function |
|
ms |
Number | Milliseconds to perform the function |
|
startValues |
Map |
<optional> |
Name value pairs of starting values (or pass in a single value) |
endValues |
Map |
<optional> |
Name value pairs of ending values (or pass in a single value) |
Example
var e=new STX.EaseMachine(Math.easeInOutCubic, 200); e.run(function(v){console.log(v)}, 100, 110);
Members
-
hasCompleted :Boolean
-
This will be true when the cubic has completed
Type:
- Boolean
Methods
-
next()
-
Returns the next set of values, or individual value
Returns:
Name value pairs of current values or current value
- Type
- Map
-
reset( [startValues], endValues)
-
Resets the EaseMachine with a new set of values
Parameters:
Name Type Argument Description startValues
Map <optional>
Name value pairs of starting values (or pass in a single value). If null then the currentValues will become the startValues (allowing for resetting or reversing of direction)
endValues
Map Name value pairs of ending values (or pass in a single value)
-
run(fc [, startValues] [, endValues] [, delayFirstRun])
-
Runs the ease machine in a loop until completion by calling next() from within a requestAnimationFrame.
Parameters:
Name Type Argument Default Description fc
function Function callback, will receive the results of STX.EaseMachine#next
startValues
Map <optional>
Name value pairs of starting values (or pass in a single value)
endValues
Map <optional>
Name value pairs of ending values (or pass in a single value)
delayFirstRun
Boolean <optional>
false Normally, the first pass of the run will happen immediately. Pass true if you want to wait for the next animation frame before beginning.
-
stop()
-
Stops the ease machine from running mid-animation. Returns the current state.
Returns:
Name value pairs of current values or current value
- Type
- Map