Skip to content

Commit

Permalink
Merge pull request #1401 from VisActor/fix/animate-zero-duration
Browse files Browse the repository at this point in the history
fix: fix issue with animate zero duration
  • Loading branch information
neuqzxy authored Aug 30, 2024
2 parents 70175a2 + 26a6da1 commit c0c6305
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vrender-core",
"comment": "fix: fix issue with animate zero duration",
"type": "none"
}
],
"packageName": "@visactor/vrender-core"
}
2 changes: 1 addition & 1 deletion packages/vrender-core/src/animate/Ticker/manual-ticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class ManualTicker extends DefaultTicker implements ITicker {
}

tickAt(time: number) {
this.tickerHandler.tick(time - this.lastFrameTime, (handler: ITickHandler) => {
this.tickerHandler.tick(time - Math.max(this.lastFrameTime, 0), (handler: ITickHandler) => {
this.handleTick(handler, { once: true });
});
}
Expand Down
7 changes: 5 additions & 2 deletions packages/vrender-core/src/animate/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ export class Animate implements IAnimate {
this.status = AnimateStatus.RUNNING;
this._onStart && this._onStart.forEach(cb => cb());
}
const end = this.setPosition(this.rawPosition + delta * this.timeScale);
const end = this.setPosition(Math.max(this.rawPosition, 0) + delta * this.timeScale);
if (end && this.status === AnimateStatus.RUNNING) {
this.status = AnimateStatus.END;
this._onEnd && this._onEnd.forEach(cb => cb());
Expand Down Expand Up @@ -776,7 +776,10 @@ export class SubAnimate implements ISubAnimate {
if (d <= 0) {
// 如果不用执行,跳过
end = true;
return end;
// 小于0的话,直接return,如果等于0,那还是得走动画逻辑,将end属性设置上去
if (d < 0) {
return end;
}
}
loop = Math.floor(rawPosition / d);
position = rawPosition - loop * d;
Expand Down

0 comments on commit c0c6305

Please sign in to comment.