Skip to content

Commit 79a5704

Browse files
authored
fixup the bug that cousin space doesn't take effect on 1-child-node (#634)
1 parent 6feb452 commit 79a5704

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/jsmind.layout_provider.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ export class LayoutProvider {
147147
this.set_visible(node.children, false);
148148
}
149149
node_outer_height = Math.max(node._data.view.height, node_outer_height);
150-
if (node.children.length > 1) {
150+
151+
if (this._should_reserve_cousin_space(node)) {
151152
node_outer_height += this.opts.cousin_space;
152153
}
153154

@@ -196,7 +197,7 @@ export class LayoutProvider {
196197
node_outer_height = 0;
197198
}
198199
node_outer_height = Math.max(node._data.view.height, node_outer_height);
199-
if (node.children.length > 1) {
200+
if (this._should_reserve_cousin_space(node)) {
200201
node_outer_height += this.opts.cousin_space;
201202
}
202203

@@ -216,6 +217,9 @@ export class LayoutProvider {
216217
}
217218
return total_height;
218219
}
220+
_should_reserve_cousin_space(node) {
221+
return node.children.length > 0 && node.parent.children.length > 1;
222+
}
219223
get_node_offset(node) {
220224
var layout_data = node._data.layout;
221225
var offset_cache = null;

0 commit comments

Comments
 (0)