Skip to content

Commit d222b6a

Browse files
committed
feat: fix bug of clipPath
1 parent a42cee0 commit d222b6a

2 files changed

Lines changed: 64 additions & 1 deletion

File tree

packages/vrender-animate/__tests__/unit/animation-runtime-attribute.test.ts

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,70 @@ describe('D3 pre-handoff animation runtime', () => {
10291029
expect(clipRect.getFinalAttribute().width).toBeCloseTo(finalLayout.width, 5);
10301030
});
10311031

1032+
test('executor update rechecks parent clip path when it is replaced after bind', () => {
1033+
const { group, ticker, graphicService } = createStageHarness('executor-update-replaced-clip-path');
1034+
const currentLayout = {
1035+
x: 266.8696428571429,
1036+
y: 404,
1037+
y1: 808,
1038+
width: 142.39017857142858,
1039+
visible: true
1040+
};
1041+
const finalLayout = {
1042+
x: 257.01875,
1043+
y: 404,
1044+
y1: 808,
1045+
width: 112.8375,
1046+
visible: true
1047+
};
1048+
const rect = createRect(currentLayout);
1049+
const staleClipRect = createRect(currentLayout);
1050+
bindGraphicService(rect as any, graphicService);
1051+
bindGraphicService(staleClipRect as any, graphicService);
1052+
rect.setFinalAttributes(currentLayout);
1053+
staleClipRect.setFinalAttributes(currentLayout);
1054+
group.appendChild(rect);
1055+
group.setAttributes({
1056+
clip: true,
1057+
path: [staleClipRect]
1058+
});
1059+
1060+
(rect as any).context = {
1061+
animationState: 'update',
1062+
data: [{ value: 10 }],
1063+
diffAttrs: {
1064+
x: finalLayout.x,
1065+
width: finalLayout.width
1066+
},
1067+
finalAttrs: finalLayout
1068+
};
1069+
rect.setFinalAttributes(finalLayout);
1070+
1071+
new AnimateExecutor(group).execute({
1072+
type: 'update',
1073+
duration: 300,
1074+
easing: 'linear'
1075+
});
1076+
1077+
const finalClipRect = createRect(finalLayout);
1078+
bindGraphicService(finalClipRect as any, graphicService);
1079+
finalClipRect.setFinalAttributes(finalLayout);
1080+
group.setAttributes({
1081+
clip: true,
1082+
path: [finalClipRect]
1083+
});
1084+
1085+
tick(ticker, 20);
1086+
expect(rect.attribute.x).toBeLessThan(currentLayout.x);
1087+
expect(rect.attribute.x).toBeGreaterThan(finalLayout.x);
1088+
expect(rect.attribute.width).toBeLessThan(currentLayout.width);
1089+
expect(rect.attribute.width).toBeGreaterThan(finalLayout.width);
1090+
expect(finalClipRect.attribute.x).toBeCloseTo(rect.attribute.x, 5);
1091+
expect(finalClipRect.attribute.width).toBeCloseTo(rect.attribute.width, 5);
1092+
expect((finalClipRect as any).baseAttributes.x).toBeCloseTo(finalLayout.x, 5);
1093+
expect((finalClipRect as any).baseAttributes.width).toBeCloseTo(finalLayout.width, 5);
1094+
});
1095+
10321096
test('executor update does not sync unrelated parent clip paths', () => {
10331097
const { group, ticker, graphicService } = createStageHarness('executor-update-unrelated-clip-path');
10341098
const currentLayout = {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ export class Update extends ACustomAnimate<Record<string, number>> {
141141

142142
const clipGraphic = path[childIndex] as any;
143143
if (!clipGraphic?.attribute || clipGraphic.type !== target.type || !this.isClipPathStaticTarget(clipGraphic)) {
144-
this.clipPathSyncDisabled = true;
145144
return;
146145
}
147146

0 commit comments

Comments
 (0)