Tween


Module hilo/tween/Tween Requires hilo/core/Class Source Tween.js
Tween class makes tweening (easing, slow motion).


Demo:

ticker.addTick(Hilo.Tween);//Tween works after being added to ticker

var view = new View({x:5, y:10});
Hilo.Tween.to(view, {
    x:100,
    y:20,
    alpha:0
}, {
    duration:1000,
    delay:500,
    ease:Hilo.Ease.Quad.EaseIn,
    onComplete:function(){
        console.log('complete');
    }
});

Properties

Property Defined
delay:Int
Tweenning delay time, measure in ms.
Tween
duration:Int
Tweening duration, measure in ms.
Tween
ease:Function
Tweening transform function, default value is null.
Tween
loop:Boolean
Does tweening loop, default value is false.
Tween
onComplete:Function
Function invoked on the end of tweening.
Tween
onStart:Function
Function invoked on the beginning of tweening.
Tween
onUpdate:Function
Function invoked on tweening update.
Tween
paused:Boolean
Is tweening paused, default value is false.
Tween
repeat:Int
Repeat times of tweening, default value is 0.
Tween
Delay time of repeating tweening, measure in ms.
Tween
reverse:Boolean
Does tweening reverse, default value is false.
Tween
target:Object
Tween target object, readonly!
Tween
time:Int
Time that tweening taken, measure in ms, readonly!
Tween

Methods

Method Defined
Tween(target:Object, fromProps:Object, toProps:Object, params:Object)
Constructor
Tween
link(tween:Tween):Tween
Link next Tween.
Tween
pause():Tween
Pause the tweening.
Tween
resume():Tween
Continue to play the tweening.
Tween
seek(time:Number, pause:Boolean):Tween
Tween jumps to some point.
Tween
setProps(fromProps:Object, toProps:Object):Tween
Set beginning properties and ending properties of tweening object.
Tween
start():Tween
Starting the tweening.
Tween
stop():Tween
Stop the tweening.
Tween
tick():Object
static Update all Tween instances.
Tween
add(tween:Tween):Object
static Add a Tween instance.
Tween
remove(tweenOrTarget:Tween|Object|Array):Object
static Remove one Tween target.
Tween
removeAll():Object
static Remove all Tween instances.
Tween
fromTo(target:Object|Array, fromProps, toProps, params):Tween|Array
static Create a tween, make target object easing from beginning properties to ending properties.
Tween
to(target:Object|Array, toProps, params):Tween|Array
static Create a tween, make target object easing from current properties to ending properties.
Tween
from(target:Object|Array, fromProps, params):Tween|Array
static Create a tween, make target object easing from beginning properties to current properties.
Tween

Property Detail

delay:Int
Tweenning delay time, measure in ms.
duration:Int
Tweening duration, measure in ms.
ease:Function
Tweening transform function, default value is null.
loop:Boolean
Does tweening loop, default value is false.
onComplete:Function
Function invoked on the end of tweening. Require 1 parameter: tween. default value is null.
onStart:Function
Function invoked on the beginning of tweening. Require 1 parameter: tween. default value is null.
onUpdate:Function
Function invoked on tweening update. Require 2 parameters: ratio, tween. default value is null.
paused:Boolean
Is tweening paused, default value is false.
repeat:Int
Repeat times of tweening, default value is 0.
repeatDelay:Int
Delay time of repeating tweening, measure in ms.
reverse:Boolean
Does tweening reverse, default value is false.
target:Object
Tween target object, readonly!
time:Int
Time that tweening taken, measure in ms, readonly!

Constructor

Tween(target:Object, fromProps:Object, toProps:Object, params:Object)
parameters
target:Object — Tween target object.
fromProps:Object — Beginning properties of target tweening object.
toProps:Object — Ending properties of target tweening object.
params:Object — Tweening parameters, include all writable Tween class properties.

Method Detail

[Static] add(tween:Tween):Object
Add a Tween instance.
parameters
tween:Tween — Tween object to add.
return
Object — Tween。
[Static] from(target:Object|Array, fromProps, params):Tween|Array
Create a tween, make target object easing from beginning properties to current properties.
parameters
target:Object|Array — Tweening target or tweening target array.
fromProps — Beginning properties of target tweening object.
params — Tweening parameters.
return
Tween|Array — An tween instance or an array of tween instance.
[Static] fromTo(target:Object|Array, fromProps, toProps, params):Tween|Array
Create a tween, make target object easing from beginning properties to ending properties.
parameters
target:Object|Array — Tweening target or tweening target array.
fromProps — Beginning properties of target tweening object.
toProps — Ending properties of target tweening object.
params — Tweening parameters.
return
Tween|Array — An tween instance or an array of tween instance.
link(tween:Tween):Tween
Link next Tween. The beginning time of next Tween depends on the delay value. If delay is a string that begins with '+' or '-', next Tween will begin at (delay) ms after or before the current tween is ended. If delay is out of previous situation, next Tween will begin at (delay) ms after the beginning point of current Tween.
parameters
tween:Tween — Tween to link.
return
Tween — next Tween, for chain calls.
pause():Tween
Pause the tweening.
return
Tween — Current Tween, for chain calls.
[Static] remove(tweenOrTarget:Tween|Object|Array):Object
Remove one Tween target.
parameters
tweenOrTarget:Tween|Object|Array — Tween object, target object or an array of object to remove
return
Object — Tween。
[Static] removeAll():Object
Remove all Tween instances.
return
Object — Tween。
resume():Tween
Continue to play the tweening.
return
Tween — Current Tween, for chain calls.
seek(time:Number, pause:Boolean):Tween
Tween jumps to some point.
parameters
time:Number — The time to jump to, range from 0 to duration.
pause:Boolean — Is paused.
return
Tween — Current Tween, for chain calls.
setProps(fromProps:Object, toProps:Object):Tween
Set beginning properties and ending properties of tweening object.
parameters
fromProps:Object — Beginning properties of target tweening object.
toProps:Object — Ending properties of target tweening object.
return
Tween — Current Tween, for chain calls.
start():Tween
Starting the tweening.
return
Tween — Current Tween, for chain calls.
stop():Tween
Stop the tweening.
return
Tween — Current Tween, for chain calls.
[Static] tick():Object
Update all Tween instances.
return
Object — Tween。
[Static] to(target:Object|Array, toProps, params):Tween|Array
Create a tween, make target object easing from current properties to ending properties.
parameters
target:Object|Array — Tweening target or tweening target array.
toProps — Ending properties of target tweening object.
params — Tweening parameters.
return
Tween|Array — An tween instance or an array of tween instance.