From 65151f4b0a30811679dac394677342346c3c22f6 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Mon, 24 Apr 2023 10:25:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=80=A7=E8=83=BD=EF=BC=9A1.?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E4=BD=8D=E7=BD=AE=E6=B2=A1=E6=9C=89=E5=8F=98?= =?UTF-8?q?=E5=8C=96=E4=B8=8D=E8=A7=A6=E5=8F=91=E4=BD=8D=E7=BD=AE=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=EF=BC=9B2.=E5=B1=95=E5=BC=80=E6=94=B6=E8=B5=B7?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=B2=A1=E6=9C=89=E5=8F=98=E5=8C=96=E4=B8=8D?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=8C=89=E9=92=AE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/Node.js | 3 +++ simple-mind-map/src/layouts/LogicalStructure.js | 10 ++++++++-- simple-mind-map/src/layouts/MindMap.js | 10 ++++++++-- simple-mind-map/src/utils/nodeExpandBtn.js | 4 ++++ 4 files changed, 23 insertions(+), 4 deletions(-) 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) }