From 3e52fa658594236d03b9733579110bb4aa2015ba Mon Sep 17 00:00:00 2001 From: wanglin <1013335014@qq.com> Date: Wed, 4 Aug 2021 23:45:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=9E=E9=80=80=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- simple-mind-map/src/Render.js | 9 +++++++-- simple-mind-map/src/layouts/Base.js | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 2dd58c31..dae74bcc 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -一个简单的web思维导图实现
\ No newline at end of file +一个简单的web思维导图实现
\ No newline at end of file diff --git a/simple-mind-map/src/Render.js b/simple-mind-map/src/Render.js index 31eed1a7..ca7b54e3 100644 --- a/simple-mind-map/src/Render.js +++ b/simple-mind-map/src/Render.js @@ -76,7 +76,7 @@ class Render { this.mindMap.on('draw_click', () => { // 清除激活状态 if (this.activeNodeList.length > 0) { - this.clearActive() + this.mindMap.execCommand('CLEAR_ACTIVE_NODE') this.mindMap.emit('node_active', null, []) } }) @@ -222,7 +222,7 @@ class Render { */ clearActive() { this.activeNodeList.forEach((item) => { - this.mindMap.execCommand('SET_NODE_ACTIVE', item, false) + this.setNodeActive(item, false) }) this.activeNodeList = [] } @@ -290,6 +290,7 @@ class Render { * @Desc: 回退 */ back(step) { + this.clearAllActive() let data = this.mindMap.command.back(step) if (data) { this.renderTree = data @@ -304,6 +305,7 @@ class Render { * @Desc: 前进 */ forward(step) { + this.clearAllActive() let data = this.mindMap.command.forward(step) if (data) { this.renderTree = data @@ -324,6 +326,9 @@ class Render { if (first.isRoot) { this.insertChildNode() } else { + if (first.layerIndex === 1) { + first.parent.initRender = true + } let index = this.getNodeIndex(first) first.parent.nodeData.children.splice(index + 1, 0, { "data": { diff --git a/simple-mind-map/src/layouts/Base.js b/simple-mind-map/src/layouts/Base.js index ce127204..c8478e32 100644 --- a/simple-mind-map/src/layouts/Base.js +++ b/simple-mind-map/src/layouts/Base.js @@ -74,6 +74,9 @@ class Base { newNode.getSize() // 数据关联实际节点 data._node = newNode + if (data.data.isActive) { + this.renderer.addActiveNode(newNode) + } } // 根节点 if (isRoot) {