From 4c9c34a0ea3ba3d5cd596774a3ad3dcfbc04a058 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Sat, 9 Sep 2023 14:43:02 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=E4=B8=8D=E5=AE=8C=E7=BE=8E=E7=9A=84?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=80=9D=E7=BB=B4=E5=AF=BC=E5=9B=BE=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E6=A6=82=E8=A6=81=E5=92=8C=E8=8A=82=E7=82=B9=E7=9A=84?= =?UTF-8?q?=E5=86=B2=E7=AA=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/layouts/MindMap.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/simple-mind-map/src/layouts/MindMap.js b/simple-mind-map/src/layouts/MindMap.js index 6d9f7bf5..35af2c04 100644 --- a/simple-mind-map/src/layouts/MindMap.js +++ b/simple-mind-map/src/layouts/MindMap.js @@ -90,6 +90,11 @@ class MindMap extends Base { cur._node.rightChildrenAreaHeight = rightChildrenAreaHeight + (rightLen + 1) * this.getMarginY(layerIndex + 1) + + // 如果存在概要,则和概要的高度取最大值 + let generalizationNodeHeight = cur._node.checkHasGeneralization() ? cur._node._generalizationNodeHeight + this.getMarginY(layerIndex + 1) : 0 + cur._node.leftChildrenAreaHeight2 = Math.max(cur._node.leftChildrenAreaHeight, generalizationNodeHeight) + cur._node.rightChildrenAreaHeight2 = Math.max(cur._node.rightChildrenAreaHeight, generalizationNodeHeight) }, true, 0 @@ -139,8 +144,8 @@ class MindMap extends Base { } // 判断子节点所占的高度之和是否大于该节点自身,大于则需要调整位置 let base = this.getMarginY(layerIndex + 1) * 2 + node.height - let leftDifference = node.leftChildrenAreaHeight - base - let rightDifference = node.rightChildrenAreaHeight - base + let leftDifference = node.leftChildrenAreaHeight2 - base + let rightDifference = node.rightChildrenAreaHeight2 - base if (leftDifference > 0 || rightDifference > 0) { this.updateBrothers(node, leftDifference / 2, rightDifference / 2) }