Skip to content

Commit

Permalink
fix: Add tween.isComplete to fix tween.onComplete throw error bug
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed Mar 14, 2019
1 parent 8126347 commit 79f96ed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/tween/Tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ return Class.create(/** @lends Tween.prototype */{
time: 0, //ready only

isStart:false,
isComplete:false,
onStart: null,
onUpdate: null,
onComplete: null,
Expand Down Expand Up @@ -186,7 +187,11 @@ return Class.create(/** @lends Tween.prototype */{
me._startTime = now() + me.delay;
me._seekTime = 0;
me._pausedTime = 0;
me._reverseFlag = 1;
me._repeatCount = 0;
me.paused = false;
me.isStart = false;
me.isComplete = false;
Tween.add(me);
return me;
},
Expand Down Expand Up @@ -323,6 +328,7 @@ return Class.create(/** @lends Tween.prototype */{
_update: function(time, forceUpdate){
var me = this;
if(me.paused && !forceUpdate) return;
if(me.isComplete) return true;

//elapsed time
var elapsed = time - me._startTime - me._pausedTime + me._seekTime;
Expand Down Expand Up @@ -376,7 +382,7 @@ return Class.create(/** @lends Tween.prototype */{
me._startTime = now() + me.repeatDelay;
me._pausedTime = 0;
}else{
complete = true;
me.isComplete = true;
}
}

Expand All @@ -389,14 +395,14 @@ return Class.create(/** @lends Tween.prototype */{
next._render(ratio);
next.time = elapsed;
Tween.add(next);
}else if(complete && (nextStartTime < 0 || nextStartTime > time)){
}else if(me.isComplete && (nextStartTime < 0 || nextStartTime > time)){
//next tween
next.start();
}
}

//complete
if(complete){
if(me.isComplete){
(callback = me.onComplete) && callback.call(me, me);
return true;
}
Expand Down

0 comments on commit 79f96ed

Please sign in to comment.