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)