From d34615b8ea922b3478e1df341f94a753b13f3bed Mon Sep 17 00:00:00 2001 From: 06wj <06wj@163.com> Date: Wed, 13 Dec 2017 12:29:14 +0800 Subject: [PATCH] fix: fix tween link bug, see #109 --- src/tween/Tween.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tween/Tween.js b/src/tween/Tween.js index 68ac8bfb..0a89f9dc 100644 --- a/src/tween/Tween.js +++ b/src/tween/Tween.js @@ -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){ @@ -136,6 +137,7 @@ return Class.create(/** @lends Tween.prototype */{ ease: null, time: 0, //ready only + isStart:false, onStart: null, onUpdate: null, onComplete: null, @@ -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; @@ -290,7 +292,7 @@ return Class.create(/** @lends Tween.prototype */{ me._next = tween; Tween.remove(tween); - return me; + return tween; }, /** @@ -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