From f9d1b4d5cf57aa9d131e42cf67e4d0e8cdbe71e4 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 14 Nov 2024 00:27:57 +0000 Subject: [PATCH] Optimized `TweenData.update` to achieve the same result with my less repetition. Also fixes an issue where a Tween that used a custom `ease` callback would glitch when the final value was set, as it would be set outside of the ease callback. It's now passed through it, no matter what. Fix #6939 --- src/tweens/tween/TweenData.js | 46 ++++++++++++++--------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/src/tweens/tween/TweenData.js b/src/tweens/tween/TweenData.js index 9fac9f739..17581519c 100644 --- a/src/tweens/tween/TweenData.js +++ b/src/tweens/tween/TweenData.js @@ -305,14 +305,28 @@ var TweenData = new Class({ this.progress = progress; this.previous = this.current; + if (!forward) + { + progress = 1 - progress; + } + + var v = this.ease(progress); + + if (this.interpolation) + { + this.current = this.interpolation(this.interpolationData, v); + } + else + { + this.current = this.start + ((this.end - this.start) * v); + } + + target[key] = this.current; + if (complete) { if (forward) { - this.current = this.end; - - target[key] = this.end; - if (this.hold > 0) { this.elapsed = this.hold; @@ -326,33 +340,9 @@ var TweenData = new Class({ } else { - this.current = this.start; - - target[key] = this.start; - this.setStateFromStart(diff); } } - else - { - if (!forward) - { - progress = 1 - progress; - } - - var v = this.ease(progress); - - if (this.interpolation) - { - this.current = this.interpolation(this.interpolationData, v); - } - else - { - this.current = this.start + ((this.end - this.start) * v); - } - - target[key] = this.current; - } this.dispatchEvent(Events.TWEEN_UPDATE, 'onUpdate'); }