Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@visactor/vchart",
"comment": "fix: preserve final attributes for exit animations when appear animations are disabled",
"type": "patch"
}
],
"packageName": "@visactor/vchart",
"email": "skie1997@outlook.com"
}
50 changes: 50 additions & 0 deletions packages/vchart/__tests__/unit/animation/manual-ticker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1583,6 +1583,56 @@ describe('manual ticker animation regressions', () => {
}
});

it('keeps bar final attributes for exit animation when appear animation is disabled', () => {
const { container, dom } = createChartContainer();
const ticker = createManualTicker();
const chart = new VChart(
{
type: 'bar',
width: 400,
height: 300,
data: [
{
id: 'barData',
values: [{ category: 'A', value: 10 }]
}
],
dataKey: 'category',
xField: 'category',
yField: 'value',
axes: [
{ orient: 'left', visible: false },
{ orient: 'bottom', visible: false }
],
animationAppear: false
} as IBarChartSpec,
{
dom,
ticker,
animation: true
}
);

chart.renderSync();

try {
const exitingBar = getBarGraphics(chart)[0];
const expectedFinalY = exitingBar.context.finalAttrs.y;
const expectedFinalY1 = exitingBar.context.finalAttrs.y1;

expect(() => {
chart.updateDataSync('barData', [{ category: 'B', value: 20 }]);
}).not.toThrow();
expect(exitingBar.context.diffState).toBe('exit');
expectClose(getGraphicFinalAttribute(exitingBar).y, expectedFinalY);
expectClose(getGraphicFinalAttribute(exitingBar).y1, expectedFinalY1);
} finally {
chart.release();
ticker.release();
removeDom(container);
}
});

it('keeps horizontal bar sorted update final y at the reordered axis positions', () => {
const { container, dom } = createChartContainer();
const ticker = createManualTicker();
Expand Down
2 changes: 2 additions & 0 deletions packages/vchart/src/mark/base/base-mark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,8 @@ export class BaseMark<T extends ICommonSpec> extends GrammarItem implements IMar
diffState,
// 从旧context中继承
reusing: g.context?.reusing,
// exit图元不会再次执行encoder,需要保留上一轮的最终属性用于退场动画
finalAttrs: g.context?.finalAttrs,
// 从旧context中继承
originalFieldX: g.context?.originalFieldX,
// 从旧context中继承
Expand Down
Loading