Skip to content

Commit

Permalink
Merge pull request #616 from VisActor/fix/clean-animation
Browse files Browse the repository at this point in the history
Fix/clean animation
  • Loading branch information
xile611 authored Jan 9, 2025
2 parents 84695de + 44ccef5 commit 7bda67c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vgrammar-core",
"comment": "fix loop animation release",
"type": "none"
}
],
"packageName": "@visactor/vgrammar-core"
}
15 changes: 14 additions & 1 deletion packages/vgrammar-core/src/graph/animation/animate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ export class Animate implements IAnimate {
);
});
if (needStopAnimation) {
// do not clear exit element in case it will animate
this.clearElementAnimation(element, false);
}
// clear animations for exit elements
else if (element.diffState === DiffState.exit) {
this.clearElementAnimation(element, false);
}
});
Expand Down Expand Up @@ -297,6 +300,16 @@ export class Animate implements IAnimate {
elementCount: animatedElements.length,
elementIndex: 0
};
// clear animator with same state
animatedElements.forEach(element => {
(this.animators.get(config.state) ?? [])
.filter(animator => animator.element === element && animator.animationOptions.id === config.id)
.forEach(animator => {
animator.stop(null, false);
this.handleAnimatorEnd(animator, false);
});
});
// run animator
animatedElements.forEach((element, index) => {
animationParameters.elementIndex = index;
// add animation parameter into parameters
Expand Down
2 changes: 1 addition & 1 deletion packages/vgrammar-core/src/graph/animation/animator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class Animator implements IAnimator {
return this;
}

stop(stopState: 'start' | 'end' = 'end', invokeCallback: boolean = true): this {
stop(stopState?: 'start' | 'end', invokeCallback: boolean = true): this {
// FIXME: wait for VRender to fix 'end' parameter
this.runnings.forEach(running => running.stop(stopState));
this.animationEnd(invokeCallback);
Expand Down

0 comments on commit 7bda67c

Please sign in to comment.