修复概要展开收起的定位错误问题

This commit is contained in:
wanglin25
2022-08-01 09:36:25 +08:00
parent f11f364d00
commit db3c2b71f5
3 changed files with 29 additions and 8 deletions

View File

@@ -85,6 +85,9 @@ class Node {
textContentWidth: 0,
textContentHeight: 0
}
// 概要节点的宽高
this._generalizationNodeWidth = 0
this._generalizationNodeHeight = 0
// 各种文字信息的间距
this.textContentItemMargin = this.mindMap.opt.textContentMargin
// 图片和文字节点的间距
@@ -94,7 +97,7 @@ class Node {
// 初始渲染
this.initRender = true
// 初始化
this.createNodeData()
// this.createNodeData()
this.getSize()
}
@@ -797,13 +800,23 @@ class Node {
this._lines = []
}
/**
* javascript comment
* @Author: 王林25
* @Date: 2022-08-01 09:27:30
* @Desc: 检查是否存在概要
*/
checkHasGeneralization() {
return !!this.nodeData.data.generalization
}
/**
* @Author: 王林
* @Date: 2022-07-31 09:41:28
* @Desc: 创建概要节点
*/
createGeneralizationNode() {
if (this.isGeneralization || !this.nodeData.data.generalization) {
if (this.isGeneralization || !this.checkHasGeneralization()) {
return
}
if (!this._generalizationLine) {
@@ -820,6 +833,8 @@ class Node {
draw: this.draw,
isGeneralization: true
})
this._generalizationNodeWidth = this._generalizationNode.width
this._generalizationNodeHeight = this._generalizationNode.height
this._generalizationNode.generalizationBelongNode = this
if (this.nodeData.data.generalization.isActive) {
this.renderer.addActiveNode(this._generalizationNode)
@@ -836,7 +851,13 @@ class Node {
if (this.isGeneralization) {
return
}
if (this.nodeData.data.expand === false || !this.nodeData.data.generalization) {
if (!this.checkHasGeneralization()) {
this.removeGeneralization()
this._generalizationNodeWidth = 0
this._generalizationNodeHeight = 0
return
}
if (this.nodeData.data.expand === false) {
this.removeGeneralization()
return
}

View File

@@ -173,7 +173,7 @@ class Base {
* @Desc: 获取节点包括概要在内的宽度
*/
getNodeWidthWithGeneralization(node) {
return Math.max(node.width, node._generalizationNode ? node._generalizationNode.width : 0)
return Math.max(node.width, node.checkHasGeneralization() ? node._generalizationNodeWidth : 0)
}
/**
@@ -182,7 +182,7 @@ class Base {
* @Desc: 获取节点包括概要在内的高度
*/
getNodeHeightWithGeneralization(node) {
return Math.max(node.height, node._generalizationNode ? node._generalizationNode.height : 0)
return Math.max(node.height, node.checkHasGeneralization() ? node._generalizationNodeHeight : 0)
}
/**
@@ -201,9 +201,9 @@ class Base {
root.children.forEach((child) => {
let {left, right, top, bottom} = walk(child)
// 概要内容的宽度
let generalizationWidth = child._generalizationNode ? child._generalizationNode.width + generalizationNodeMargin : 0
let generalizationWidth = child.checkHasGeneralization() ? child._generalizationNodeWidth + generalizationNodeMargin : 0
// 概要内容的高度
let generalizationHeight = child._generalizationNode ? child._generalizationNode.height + generalizationNodeMargin : 0
let generalizationHeight = child.checkHasGeneralization() ? child._generalizationNodeHeight + generalizationNodeMargin : 0
if (left < _left) {
_left = left - (isLeft ? generalizationWidth : 0)
}

View File

@@ -145,7 +145,7 @@ class CatalogOrganization extends Base {
loop(item, width)
})
} else {
width += node.width + (node._generalizationNode ? node._generalizationNode.width + this.mindMap.themeConfig.generalizationNodeMargin : 0)
width += node.width
widthArr.push(width)
}
}