Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix auto fit not effect when disable element animation #6342

Merged
merged 1 commit into from
Sep 18, 2024
Merged
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
6 changes: 4 additions & 2 deletions packages/g6/src/runtime/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ export class LayoutController {
// 无迭代的布局,直接返回终态位置 / Layout without iteration, return final position directly
const layoutResult = await layout.execute(data);
if (animation) {
this.updateElementPosition(layoutResult, animation);
const animationResult = this.updateElementPosition(layoutResult, animation);
await animationResult?.finished;
}
return layoutResult;
}
Expand Down Expand Up @@ -200,7 +201,8 @@ export class LayoutController {
applyTreeLayoutOffset(layoutPreset, offset);
this.updateElementPosition(layoutPreset, false);

this.updateElementPosition(layoutResult, animation);
const animationResult = this.updateElementPosition(layoutResult, animation);
await animationResult?.finished;
}

return layoutResult;
Expand Down
9 changes: 7 additions & 2 deletions packages/g6/src/utils/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,21 @@ export function layoutAdapter(
const { nodes = [], edges = [], combos = [] } = data;
const nodesToLayout: LayoutNodeData[] = nodes.map((datum) => {
const id = idOf(datum);
const { data, style, combo } = datum;
const { data, style, combo, ...rest } = datum;

const result = {
id,
data: {
// grid 布局会直接读取 data[sortBy],兼容处理,需要避免用户 data 下使用 data, style 等字段
// The grid layout will directly read data[sortBy], compatible processing, need to avoid users using data, style and other fields under data
...data,
data,
// antv-dagre 会读取 data.parentId
// antv-dagre will read data.parentId
...(combo ? { parentId: combo } : {}),
style,
...rest,
},
style: { ...style },
};
// 一些布局会从 data 中读取位置信息
if (style?.x) Object.assign(result.data, { x: style.x });
Expand Down
Loading