Skip to content

Commit

Permalink
fix: fix auto fit not effect when disable element animation (#6342)
Browse files Browse the repository at this point in the history
Co-authored-by: antv <[email protected]>
  • Loading branch information
Aarebecca and antv authored Sep 18, 2024
1 parent b80f1eb commit 5cbd89c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit 5cbd89c

Please sign in to comment.