Skip to content

Commit 2f54f70

Browse files
authored
Merge pull request #2030 from VisActor/fix/fix-stage-animate-afterRender-check
fix: fix issue of stageAniamte afterRender
2 parents 9f3a543 + 9e08000 commit 2f54f70

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

packages/vrender-animate/src/custom/custom-animate.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import type { ComponentAnimator } from '../component';
2-
import type { EasingType, IAnimateStepType, ICustomAnimate, Stage } from '@visactor/vrender-core';
2+
import {
3+
AnimateStatus,
4+
type EasingType,
5+
type IAnimateStepType,
6+
type ICustomAnimate,
7+
type Stage
8+
} from '@visactor/vrender-core';
39
import { Step } from '../step';
410

511
export abstract class ACustomAnimate<T> extends Step implements ICustomAnimate {
@@ -56,6 +62,7 @@ export abstract class AComponentAnimate<T> extends ACustomAnimate<T> {
5662
export abstract class AStageAnimate<T> extends ACustomAnimate<T> {
5763
willCallBeforeStageRender: boolean = true;
5864
willCallAfterStageRender: boolean = true;
65+
checkStatusAfterRender: boolean = true;
5966
constructor(customFrom: T, customTo: T, duration: number, easing: EasingType, params?: any) {
6067
super(customFrom, customTo, duration, easing, params);
6168
this.props = {} as T;
@@ -114,6 +121,10 @@ export abstract class AStageAnimate<T> extends ACustomAnimate<T> {
114121
if (outputCanvas) {
115122
this.renderToStage(stage, outputCanvas);
116123
}
124+
// 检查是否需要移除动画
125+
if (this.checkStatusAfterRender && this.animate.status === AnimateStatus.END) {
126+
this.animate.timeline.removeAnimate(this.animate);
127+
}
117128
};
118129

119130
protected renderToStage(stage: Stage, canvas: HTMLCanvasElement): HTMLCanvasElement | void | null | false {

packages/vrender-animate/src/timeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class DefaultTimeline extends EventEmitter implements ITimeline {
1414
protected tail: AnimateNode | null = null;
1515
protected animateMap: Map<IAnimate, AnimateNode> = new Map();
1616
protected _animateCount: number = 0;
17-
declare protected paused: boolean;
17+
protected declare paused: boolean;
1818

1919
// 添加必要的属性
2020
protected _playSpeed: number = 1;

0 commit comments

Comments
 (0)