diff --git a/simple-mind-map/src/Node.js b/simple-mind-map/src/Node.js index 3a787edc..c7bf3a57 100644 --- a/simple-mind-map/src/Node.js +++ b/simple-mind-map/src/Node.js @@ -67,6 +67,7 @@ class Node { this._noteData = null this.noteEl = null this._expandBtn = null + this._lastExpandBtnType = null this._openExpandNode = null this._closeExpandNode = null this._fillExpandNode = null @@ -436,6 +437,8 @@ class Node { this.renderGeneralization() // 更新节点位置 let t = this.group.transform() + // 如果节点位置没有变化,则返回 + if (this.left === t.translateX && this.top === t.translateY) return if (!isLayout && enableNodeTransitionMove) { this.group .animate(nodeTransitionMoveDuration) diff --git a/simple-mind-map/src/layouts/LogicalStructure.js b/simple-mind-map/src/layouts/LogicalStructure.js index a9ed8ff2..dde3a157 100644 --- a/simple-mind-map/src/layouts/LogicalStructure.js +++ b/simple-mind-map/src/layouts/LogicalStructure.js @@ -245,9 +245,15 @@ class LogicalStructure extends Base { let nodeUseLineStyleOffset = this.mindMap.themeConfig.nodeUseLineStyle ? height / 2 : 0 + // 位置没有变化则返回 + let _x = width + let _y = height / 2 + nodeUseLineStyleOffset + if (_x === translateX && _y === translateY) { + return + } btn.translate( - width - translateX, - height / 2 - translateY + nodeUseLineStyleOffset + _x - translateX, + _y - translateY ) } diff --git a/simple-mind-map/src/layouts/MindMap.js b/simple-mind-map/src/layouts/MindMap.js index 384c301a..48b9bdd8 100644 --- a/simple-mind-map/src/layouts/MindMap.js +++ b/simple-mind-map/src/layouts/MindMap.js @@ -310,8 +310,14 @@ class MindMap extends Base { let nodeUseLineStyleOffset = this.mindMap.themeConfig.nodeUseLineStyle ? height / 2 : 0 - let x = (node.dir === 'left' ? 0 - expandBtnSize : width) - translateX - let y = height / 2 - translateY + nodeUseLineStyleOffset + // 位置没有变化则返回 + let _x = (node.dir === 'left' ? 0 - expandBtnSize : width) + let _y = height / 2 + nodeUseLineStyleOffset + if (_x === translateX && _y === translateY) { + return + } + let x = _x - translateX + let y = _y - translateY btn.translate(x, y) } diff --git a/simple-mind-map/src/utils/nodeExpandBtn.js b/simple-mind-map/src/utils/nodeExpandBtn.js index 2119863c..347b5b69 100644 --- a/simple-mind-map/src/utils/nodeExpandBtn.js +++ b/simple-mind-map/src/utils/nodeExpandBtn.js @@ -32,6 +32,8 @@ function createExpandNodeContent() { // 创建或更新展开收缩按钮内容 function updateExpandBtnNode() { + // 如果本次和上次的展开状态一样则返回 + if (this.nodeData.data.expand === this._lastExpandBtnType) return if (this._expandBtn) { this._expandBtn.clear() } @@ -39,8 +41,10 @@ function updateExpandBtnNode() { let node if (this.nodeData.data.expand === false) { node = this._openExpandNode + this._lastExpandBtnType = false } else { node = this._closeExpandNode + this._lastExpandBtnType = true } if (this._expandBtn) this._expandBtn.add(this._fillExpandNode).add(node) }