a basic tween object for others to build on
npm install 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:
``js
var array = require('tween-array')
var ticker = require('tween-ticker')
var start = [25, 15],
end = [10, 10]
ticker.push(array(start, end, { duration: 2 }))
.on('complete', function(ev) {
console.log("result:", ev.target)
})
`

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
#### cancel()
Cancels a tween. Returns this for chaining. Next time this tween is ticked, it will:
- emit a "cancelling" event"complete"
- become inactive and stop updating the target
- emit a event
A ticker engine might then choose to remove the tween from the queue.
#### 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 to cancel()complete
- triggered when the tween is completedupdate
- triggered after the tween updates its values
--
See test/array.js for an example of a custom array interpolation.
Implementors might subclass like so:
`js
var Base = require('tween-base')
var inherits = require('inherits')
function MyTween(target, opt) {
Base.call(this, opt)
this.target = target
}
inherits(MyTween, Base)
//called before 'start' event
MyTween.prototype.ready = function() {
//this is where you might store the current
//state of "target" so that you can interpolate
//from start to end
}
MyTween.prototype.lerp = function(alpha) {
//interpolate "target" from start to end using alpha
}
``
MIT, see LICENSE.md for details.