mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
代码优化:1.将render类的removeActiveNode函数名称改为removeNodeFromActiveList;2.addNodeToActiveList和removeNodeFromActiveList方法增加修改节点的激活状态数据
This commit is contained in:
parent
9221c404ee
commit
d6ae06dbd6
@ -421,16 +421,18 @@ class Render {
|
||||
addNodeToActiveList(node) {
|
||||
const index = this.findActiveNodeIndex(node)
|
||||
if (index === -1) {
|
||||
this.mindMap.execCommand('SET_NODE_ACTIVE', node, true)
|
||||
this.activeNodeList.push(node)
|
||||
}
|
||||
}
|
||||
|
||||
// 在激活列表里移除某个节点
|
||||
removeActiveNode(node) {
|
||||
// 在激活列表里移除某个节点
|
||||
removeNodeFromActiveList(node) {
|
||||
let index = this.findActiveNodeIndex(node)
|
||||
if (index === -1) {
|
||||
return
|
||||
}
|
||||
this.mindMap.execCommand('SET_NODE_ACTIVE', node, false)
|
||||
this.activeNodeList.splice(index, 1)
|
||||
}
|
||||
|
||||
@ -448,13 +450,7 @@ class Render {
|
||||
null,
|
||||
node => {
|
||||
if (!node.nodeData.data.isActive) {
|
||||
node.nodeData.data.isActive = true
|
||||
this.addNodeToActiveList(node)
|
||||
// 激活节点需要显示展开收起按钮
|
||||
node.showExpandBtn()
|
||||
setTimeout(() => {
|
||||
node.updateNodeActive()
|
||||
}, 0)
|
||||
}
|
||||
},
|
||||
null,
|
||||
@ -1017,10 +1013,10 @@ class Render {
|
||||
generalization: null
|
||||
})
|
||||
node.generalizationBelongNode.update()
|
||||
this.removeActiveNode(node)
|
||||
this.removeNodeFromActiveList(node)
|
||||
i--
|
||||
} else {
|
||||
this.removeActiveNode(node)
|
||||
this.removeNodeFromActiveList(node)
|
||||
this.removeOneNode(node)
|
||||
i--
|
||||
}
|
||||
@ -1139,7 +1135,7 @@ class Render {
|
||||
return copyNodeTree({}, node, true)
|
||||
})
|
||||
nodeList.forEach(node => {
|
||||
this.removeActiveNode(node)
|
||||
this.removeNodeFromActiveList(node)
|
||||
this.removeOneNode(node)
|
||||
})
|
||||
this.mindMap.emit('node_active', null, [...this.activeNodeList])
|
||||
@ -1157,7 +1153,7 @@ class Render {
|
||||
})
|
||||
nodeList.forEach(item => {
|
||||
this.checkNodeLayerChange(item, toNode)
|
||||
this.removeActiveNode(item)
|
||||
this.removeNodeFromActiveList(item)
|
||||
this.removeOneNode(item)
|
||||
toNode.nodeData.children.push(item.nodeData)
|
||||
})
|
||||
|
||||
@ -437,8 +437,7 @@ class Node {
|
||||
this,
|
||||
this.renderer.activeNodeList
|
||||
)
|
||||
this.mindMap.execCommand('SET_NODE_ACTIVE', this, !isActive)
|
||||
this.mindMap.renderer[isActive ? 'removeActiveNode' : 'addNodeToActiveList'](
|
||||
this.mindMap.renderer[isActive ? 'removeNodeFromActiveList' : 'addNodeToActiveList'](
|
||||
this
|
||||
)
|
||||
this.mindMap.emit('node_active', isActive ? null : this, [
|
||||
@ -516,7 +515,6 @@ class Node {
|
||||
}
|
||||
this.mindMap.emit('before_node_active', this, this.renderer.activeNodeList)
|
||||
this.renderer.clearActiveNodeList()
|
||||
this.mindMap.execCommand('SET_NODE_ACTIVE', this, true)
|
||||
this.renderer.addNodeToActiveList(this)
|
||||
this.mindMap.emit('node_active', this, [...this.renderer.activeNodeList])
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ function removeGeneralization() {
|
||||
}
|
||||
if (this._generalizationNode) {
|
||||
// 删除概要节点时要同步从激活节点里删除
|
||||
this.renderer.removeActiveNode(this._generalizationNode)
|
||||
this.renderer.removeNodeFromActiveList(this._generalizationNode)
|
||||
this._generalizationNode.remove()
|
||||
this._generalizationNode = null
|
||||
}
|
||||
|
||||
@ -221,14 +221,12 @@ class Select {
|
||||
if (node.nodeData.data.isActive) {
|
||||
return
|
||||
}
|
||||
this.mindMap.execCommand('SET_NODE_ACTIVE', node, true)
|
||||
this.mindMap.renderer.addNodeToActiveList(node)
|
||||
} else if (node.nodeData.data.isActive) {
|
||||
if (!node.nodeData.data.isActive) {
|
||||
return
|
||||
}
|
||||
this.mindMap.execCommand('SET_NODE_ACTIVE', node, false)
|
||||
this.mindMap.renderer.removeActiveNode(node)
|
||||
this.mindMap.renderer.removeNodeFromActiveList(node)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user