mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 22:08:25 +08:00
优化代码:1.将render类的setNodeActive方法的部分逻辑移到node类;2.将node类的updateNodeActive方法名称改为updateNodeActiveClass
This commit is contained in:
@@ -1195,15 +1195,7 @@ class Render {
|
||||
this.mindMap.execCommand('SET_NODE_DATA', node, {
|
||||
isActive: active
|
||||
})
|
||||
if (node.group) {
|
||||
// 切换激活状态,需要切换展开收起按钮的显隐
|
||||
if (active) {
|
||||
node.showExpandBtn()
|
||||
} else {
|
||||
node.hideExpandBtn()
|
||||
}
|
||||
node.updateNodeActive()
|
||||
}
|
||||
node.updateNodeByActive(active)
|
||||
}
|
||||
|
||||
// 设置节点是否展开
|
||||
|
||||
@@ -524,7 +524,7 @@ class Node {
|
||||
if (!this.group) {
|
||||
return
|
||||
}
|
||||
this.updateNodeActive()
|
||||
this.updateNodeActiveClass()
|
||||
let { alwaysShowExpandBtn } = this.mindMap.opt
|
||||
if (alwaysShowExpandBtn) {
|
||||
// 需要移除展开收缩按钮
|
||||
@@ -600,12 +600,25 @@ class Node {
|
||||
}
|
||||
|
||||
// 更新节点激活状态
|
||||
updateNodeActive() {
|
||||
updateNodeActiveClass() {
|
||||
if (!this.group) return
|
||||
const isActive = this.getData('isActive')
|
||||
this.group[isActive ? 'addClass' : 'removeClass']('active')
|
||||
}
|
||||
|
||||
// 根据是否激活更新节点
|
||||
updateNodeByActive(active) {
|
||||
if (this.group) {
|
||||
// 切换激活状态,需要切换展开收起按钮的显隐
|
||||
if (active) {
|
||||
this.showExpandBtn()
|
||||
} else {
|
||||
this.hideExpandBtn()
|
||||
}
|
||||
this.updateNodeActiveClass()
|
||||
}
|
||||
}
|
||||
|
||||
// 递归渲染
|
||||
render(callback = () => {}) {
|
||||
// 节点
|
||||
|
||||
Reference in New Issue
Block a user