Skip to content

Commit

Permalink
Optimized TweenData.update to achieve the same result with my less …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
photonstorm committed Nov 14, 2024
1 parent ec42bd5 commit f9d1b4d
Showing 1 changed file with 18 additions and 28 deletions.
46 changes: 18 additions & 28 deletions src/tweens/tween/TweenData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
}
Expand Down

0 comments on commit f9d1b4d

Please sign in to comment.