Skip to content

Commit

Permalink
fix: fix tween link bug, see #109
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed Dec 13, 2017
1 parent bbd5748 commit d34615b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/tween/Tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ return Class.create(/** @lends Tween.prototype */{
}

for(var p in params) me[p] = params[p];
me.setProps(fromProps, toProps);
me._fromProps = fromProps;
me._toProps = toProps;

//for old version compatiblity
if(!params.duration && params.time){
Expand All @@ -136,6 +137,7 @@ return Class.create(/** @lends Tween.prototype */{
ease: null,
time: 0, //ready only

isStart:false,
onStart: null,
onUpdate: null,
onComplete: null,
Expand Down Expand Up @@ -268,13 +270,13 @@ return Class.create(/** @lends Tween.prototype */{
* @language=en
* 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.
* @param {Tween} tween Tween to link.
* @returns {Tween} Current Tween, for chain calls.
* @returns {Tween} next Tween, for chain calls.
*/
/**
* @language=zh
* 连接下一个Tween变换。其开始时间根据delay值不同而不同。当delay值为字符串且以'+'或'-'开始时,Tween的开始时间从当前变换结束点计算,否则以当前变换起始点计算。
* @param {Tween} tween 要连接的Tween变换。
* @returns {Tween} Tween变换本身。可用于链式调用。
* @returns {Tween} 下一个Tween。可用于链式调用。
*/
link: function(tween){
var me = this, delay = tween.delay, startTime = me._startTime;
Expand All @@ -290,7 +292,7 @@ return Class.create(/** @lends Tween.prototype */{

me._next = tween;
Tween.remove(tween);
return me;
return tween;
},

/**
Expand Down Expand Up @@ -351,7 +353,13 @@ return Class.create(/** @lends Tween.prototype */{
}

//start callback
if(me.time == 0 && (callback = me.onStart)) callback.call(me, me);
if(!me.isStart) {
me.setProps(me._fromProps, me._toProps);
me.isStart = true;
if(me.onStart){
me.onStart.call(me, me);
}
};
me.time = elapsed;

//render & update callback
Expand Down

0 comments on commit d34615b

Please sign in to comment.