From fb41653d799389d6b01776f30350f28f76d3432a Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Sat, 9 Sep 2023 15:42:21 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=E4=B8=8D=E5=AE=8C=E7=BE=8E=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=9B=AE=E5=BD=95=E7=BB=84=E7=BB=87=E5=9B=BE=E6=A6=82?= =?UTF-8?q?=E8=A6=81=E5=92=8C=E8=8A=82=E7=82=B9=E5=86=B2=E7=AA=81=E7=9A=84?= =?UTF-8?q?=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/Base.js | 8 ++++++-- simple-mind-map/src/layouts/CatalogOrganization.js | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/simple-mind-map/src/layouts/Base.js b/simple-mind-map/src/layouts/Base.js index 92c4e0e4..6199059f 100644 --- a/simple-mind-map/src/layouts/Base.js +++ b/simple-mind-map/src/layouts/Base.js @@ -202,9 +202,13 @@ class Base { } // 递归计算节点的宽度 - getNodeAreaWidth(node) { + getNodeAreaWidth(node, withGeneralization = false) { let widthArr = [] + let totalGeneralizationNodeWidth = 0 let loop = (node, width) => { + if (withGeneralization && node.checkHasGeneralization()) { + totalGeneralizationNodeWidth += node._generalizationNodeWidth + } if (node.children.length) { width += node.width / 2 node.children.forEach(item => { @@ -216,7 +220,7 @@ class Base { } } loop(node, 0) - return Math.max(...widthArr) + return Math.max(...widthArr) + totalGeneralizationNodeWidth } // 二次贝塞尔曲线 diff --git a/simple-mind-map/src/layouts/CatalogOrganization.js b/simple-mind-map/src/layouts/CatalogOrganization.js index 3e780c0d..615c3dab 100644 --- a/simple-mind-map/src/layouts/CatalogOrganization.js +++ b/simple-mind-map/src/layouts/CatalogOrganization.js @@ -87,11 +87,11 @@ class CatalogOrganization extends Base { totalLeft += cur.width + marginX }) } else { - let totalTop = node.top + node.height + marginY + (this.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) + let totalTop = node.top + this.getNodeHeightWithGeneralization(node) + marginY + (this.getNodeActChildrenLength(node) > 0 ? node.expandBtnSize : 0) node.children.forEach(cur => { cur.left = node.left + node.width * 0.5 cur.top = totalTop - totalTop += cur.height + marginY + (this.getNodeActChildrenLength(cur) > 0 ? cur.expandBtnSize : 0) + totalTop += this.getNodeHeightWithGeneralization(cur) + marginY + (this.getNodeActChildrenLength(cur) > 0 ? cur.expandBtnSize : 0) }) } } @@ -112,7 +112,7 @@ class CatalogOrganization extends Base { } // 调整left if (parent && parent.isRoot) { - let areaWidth = this.getNodeAreaWidth(node) + let areaWidth = this.getNodeAreaWidth(node, true) let difference = areaWidth - node.width if (difference > 0) { this.updateBrothersLeft(node, difference) @@ -124,7 +124,7 @@ class CatalogOrganization extends Base { let marginY = this.getMarginY(layerIndex + 1) let totalHeight = node.children.reduce((h, item) => { - return h + item.height + (this.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) + return h + this.getNodeHeightWithGeneralization(item) + (this.getNodeActChildrenLength(item) > 0 ? item.expandBtnSize : 0) }, 0) + len * marginY this.updateBrothersTop(node, totalHeight)