diff --git a/packages/g6/__tests__/demos/behavior-expand-collapse-node.ts b/packages/g6/__tests__/demos/behavior-expand-collapse-node.ts
index 0a579662e5f..0d070a813c2 100644
--- a/packages/g6/__tests__/demos/behavior-expand-collapse-node.ts
+++ b/packages/g6/__tests__/demos/behavior-expand-collapse-node.ts
@@ -9,7 +9,7 @@ export const behaviorExpandCollapseNode: TestCase = async (context) => {
id: 'A',
children: [
{ id: 'B', children: [{ id: 'D' }, { id: 'E' }] },
- { id: 'C', children: [{ id: 'F' }, { id: 'G' }] },
+ { id: 'C', children: [{ id: 'F' }, { id: 'G' },], style: { collapsed: true } },
],
}),
node: {
@@ -26,7 +26,8 @@ export const behaviorExpandCollapseNode: TestCase = async (context) => {
type: 'dendrogram',
nodeSep: 30,
rankSep: 100,
- preLayout: false,
+ preLayout: true,
+ isLayoutInvisibleNodes: true,
},
behaviors: [{ type: 'collapse-expand', trigger: 'click', align: false }, 'drag-element'],
});
diff --git a/packages/g6/src/runtime/element.ts b/packages/g6/src/runtime/element.ts
index db21e982349..a59b774b12c 100644
--- a/packages/g6/src/runtime/element.ts
+++ b/packages/g6/src/runtime/element.ts
@@ -704,8 +704,8 @@ export class ElementController {
* @param animation - 是否使用动画,默认为 true | Whether to use animation, default is true
*/
public async expandNode(id: ID, options: CollapseExpandNodeOptions): Promise {
- const { model, layout } = this.context;
- const { animation, align } = options;
+ const { model } = this.context;
+ const { animation } = options;
const position = positionOf(model.getNodeData([id])[0]);
// 重新计算数据 / Recalculate data
@@ -885,10 +885,4 @@ export interface CollapseExpandNodeOptions {
* Whether to use animation
*/
animation?: boolean;
- /**
- * 保证展开/收起的节点位置不变
- *
- * Ensure that the position of the expanded/collapsed node remains unchanged
- */
- align?: boolean;
}
diff --git a/packages/site/docs/api/element.zh.md b/packages/site/docs/api/element.zh.md
index fb997306296..00b98fc25bb 100644
--- a/packages/site/docs/api/element.zh.md
+++ b/packages/site/docs/api/element.zh.md
@@ -380,9 +380,7 @@ await graph.collapseElement('combo1');
await graph.collapseElement('combo1', true);
// 收起并保证展开/收起的节点位置不变
-await graph.collapseElement('combo1', {
- align: true,
-});
+await graph.collapseElement('combo1', {});
```
### Graph.expandElement(id, options)