tween-base
This is a base class for tween types, built alongside tweenr and tween-ticker. It is not inherently tied to those modules, and may prove useful outside of those environments.
Usually you won't require tween-base
itself, but the modules that build on top of it. Example:
var array = var ticker = var start = 25 15 end = 10 10 ticker
Usage
This describes the public (user-facing) API for tweens.
tween = BaseTween(opt)
Where options usually describes the following:
delay
in time units, default 0duration
in time units, default 0ease
is an easing function -- tween engines may want to allow strings for user friendliness
methods
cancel()
Cancels a tween. Returns this for chaining. Next time this tween is ticked, it will:
- emit a
"cancelling"
event - become inactive and stop updating the target
- emit a
"complete"
event
A ticker engine might then choose to remove the tween from the queue.
members
tween.on(event, func)
A tween is an event emitter with the following events:
start
triggered when the tween is first startedcancelling
triggered before the tween completes, initiating from a call tocancel()
complete
triggered when the tween is completedupdate
triggered after the tween updates its values
--
inheriting
See test/array.js for an example of a custom array interpolation.
Implementors might subclass like so:
var Base = var inherits = { Base thistarget = target} //called before 'start' event MyTweenprototype { //this is where you might store the current //state of "target" so that you can interpolate //from start to end} MyTweenprototype { //interpolate "target" from start to end using alpha}
License
MIT, see LICENSE.md for details.