transform.js
Simple JavaScript transformations, e.g. for tweening, that can be paused, resumed and canceled.
Installation
npm install transform-js
Usage
var t = ;
t
: An object with methods to control the transformation.from
: The start value.to
: The end value.update
: A function that receives the current value of the transformation.options
: An object to configure the transformation (optional):duration
: Duration for the transformation.easing
: An easing function or name of an easing function from node packageeases
.fps
: Frames per second to use.
after
: Callback for when the transformation has stopped or is canceled (optional).
var transformation = transformation;var t = ; { // ... console;} tstart;
Canceling
You can cancel a transformation:
t;
Canceling stops the transformation. The last value will be the current value of the transformation.
Stopping
You can stop a running transformation:
t;
The last value will be the to
value of the transformation.
Pause/resume
A transformation can be paused and resumed:
tstart; ; ;