diff --git a/simple-mind-map/src/Render.js b/simple-mind-map/src/Render.js index f0261ee2..3f6caa71 100644 --- a/simple-mind-map/src/Render.js +++ b/simple-mind-map/src/Render.js @@ -257,6 +257,7 @@ class Render { // 重新渲染需要清除激活状态 if (this.reRender) { this.clearActive() + this.layout.clearNodePool() } // 计算布局 this.layout.doLayout(root => { diff --git a/simple-mind-map/src/layouts/Base.js b/simple-mind-map/src/layouts/Base.js index e6827e1e..0111c33a 100644 --- a/simple-mind-map/src/layouts/Base.js +++ b/simple-mind-map/src/layouts/Base.js @@ -43,10 +43,15 @@ class Base { this.nodePool[uid] = node // 如果总缓存数量达到1000,直接清空 if (Object.keys(this.nodePool).length > 1000) { - this.nodePool = {} + this.clearNodePool() } } + // 清空节点存储池 + clearNodePool() { + this.nodePool = {} + } + // 检查当前来源是否需要重新计算节点大小 checkIsNeedResizeSources() { return [CONSTANTS.CHANGE_THEME, CONSTANTS.TRANSFORM_TO_NORMAL_NODE].includes(this.renderer.renderSource)