Class: EaseMachine

CIQ. EaseMachine


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), where:

  • 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 Object.<string, number> | number <optional>

Name/value pairs of starting values, or a single value.

endValues Object.<string, number> | number <optional>

Name/value pairs of ending values, or a single value.

Example
let e = new CIQ.EaseMachine(Math["easeInOutCubic"], 200);
e.run(
	function (v) {
		console.log(v);
	},
	100,
	110
);

Members


hasCompleted :boolean

This will be false while the ease machine is completing

Type:
  • boolean

Methods


reset(startValues, endValues)

Resets the ease machine with a new set of values.

Parameters:
Name Type Description
startValues Object.<string, number> | number

Name/value pairs of starting values, or a single value. If null, the endValues become the startValues (allowing for resetting or reversing of direction).

endValues Object.<string, number> | number

Name/value pairs of ending values, or 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 which receives the results of CIQ.EaseMachine#next.

startValues Object.<string, number> | number <optional>

Name/value pairs of starting values, or a single value.

endValues Object.<string, number> | number <optional>

Name/value pairs of ending values, or a single value.

delayFirstRun boolean <optional>
false

Normally, the first pass of the run happens 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 the current value.

Type
Object.<string, number>