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
5 changes: 3 additions & 2 deletions packages/g6/__tests__/demos/behavior-expand-collapse-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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'],
});
Expand Down
10 changes: 2 additions & 8 deletions packages/g6/src/runtime/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,8 @@ export class ElementController {
* @param animation - <zh/> 是否使用动画,默认为 true | <en/> Whether to use animation, default is true
*/
public async expandNode(id: ID, options: CollapseExpandNodeOptions): Promise<void> {
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
Expand Down Expand Up @@ -885,10 +885,4 @@ export interface CollapseExpandNodeOptions {
* <en/> Whether to use animation
*/
animation?: boolean;
/**
* <zh/> 保证展开/收起的节点位置不变
*
* <en/> Ensure that the position of the expanded/collapsed node remains unchanged
*/
align?: boolean;
}
4 changes: 1 addition & 3 deletions packages/site/docs/api/element.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,7 @@ await graph.collapseElement('combo1');
await graph.collapseElement('combo1', true);

// 收起并保证展开/收起的节点位置不变
await graph.collapseElement('combo1', {
align: true,
});
await graph.collapseElement('combo1', {});
Comment thread
HawtinZeng marked this conversation as resolved.
```

### Graph.expandElement(id, options)
Expand Down
Loading