Skip to content

Commit ec376b9

Browse files
committed
fix: fix issue of animation channel
1 parent 2f438c3 commit ec376b9

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ export class AnimateExecutor implements IAnimateExecutor {
358358
}
359359
from = parsedFromProps.from;
360360
}
361+
if (parsedFromProps.hasAttrs) {
362+
graphic.setAttributes(parsedFromProps.attrOutChannel);
363+
}
361364

362365
this._handleRunAnimate(
363366
animate,
@@ -559,6 +562,9 @@ export class AnimateExecutor implements IAnimateExecutor {
559562
}
560563
from = parsedFromProps.from;
561564
}
565+
if (parsedFromProps.hasAttrs) {
566+
graphic.setAttributes(parsedFromProps.attrOutChannel);
567+
}
562568
const custom = effect.custom ?? AnimateExecutor.builtInAnimateMap[type];
563569
const customType = effect.custom ? (effect as any).customType : getCustomType(custom);
564570
this._handleRunAnimate(
@@ -645,14 +651,22 @@ export class AnimateExecutor implements IAnimateExecutor {
645651
private createPropsFromChannel(
646652
channel: IAnimationChannelAttrs | IAnimationChannelAttributes | undefined,
647653
graphic: IGraphic
648-
): { from: Record<string, any> | null; props: Record<string, any> } {
654+
): {
655+
from: Record<string, any> | null;
656+
props: Record<string, any>;
657+
attrOutChannel: Record<string, any> | null;
658+
hasAttrs: boolean;
659+
} {
649660
const props: Record<string, any> = {};
650661
let from: Record<string, any> | null = null;
651-
662+
const attrOutChannel: Record<string, any> | null = {};
663+
let hasAttrs = false;
652664
if (!channel) {
653665
return {
654666
from,
655-
props
667+
props,
668+
attrOutChannel,
669+
hasAttrs
656670
};
657671
}
658672

@@ -681,31 +695,21 @@ export class AnimateExecutor implements IAnimateExecutor {
681695

682696
const diffAttrs = graphic.context?.diffAttrs;
683697
if (diffAttrs) {
684-
const batchAttrs: Record<string, any> = {};
685-
let hasAttrs = false;
686698
for (const key in diffAttrs) {
687699
const value = (diffAttrs as any)[key];
688700
if (value === undefined) {
689701
continue;
690702
}
691703
if (!props.hasOwnProperty(key)) {
692-
batchAttrs[key] = value;
704+
attrOutChannel[key] = value;
693705
hasAttrs = true;
694706
}
695707
}
696-
if (hasAttrs) {
697-
const batchKeys = Object.keys(batchAttrs);
698-
if (batchKeys.length) {
699-
graphic.setAttributes(batchAttrs);
700-
}
701-
}
702708
}
703709
} else {
704710
const diffAttrs = graphic.context?.diffAttrs;
705711
if (diffAttrs) {
706712
const channelSet = new Set(channel as string[]);
707-
const batchAttrs: Record<string, any> = {};
708-
let hasAttrs = false;
709713
for (const key in diffAttrs) {
710714
const value = (diffAttrs as any)[key];
711715
if (value === undefined) {
@@ -714,22 +718,18 @@ export class AnimateExecutor implements IAnimateExecutor {
714718
if (channelSet.has(key)) {
715719
props[key] = value;
716720
} else {
717-
batchAttrs[key] = value;
721+
attrOutChannel[key] = value;
718722
hasAttrs = true;
719723
}
720724
}
721-
if (hasAttrs) {
722-
const batchKeys = Object.keys(batchAttrs);
723-
if (batchKeys.length) {
724-
graphic.setAttributes(batchAttrs);
725-
}
726-
}
727725
}
728726
}
729727

730728
return {
731729
from,
732-
props
730+
props,
731+
attrOutChannel,
732+
hasAttrs
733733
};
734734
}
735735

0 commit comments

Comments
 (0)