diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index 3aa2500e..230713cb 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -382,7 +382,7 @@ class Render { // 检索某个节点在激活列表里的索引 findActiveNodeIndex(node) { return this.activeNodeList.findIndex(item => { - return item === node + return item.uid === node.uid }) } @@ -390,7 +390,7 @@ class Render { getNodeIndex(node) { return node.parent ? node.parent.children.findIndex(item => { - return item === node + return item.uid === node.uid }) : 0 } @@ -553,7 +553,7 @@ class Render { let parent = node.parent let childList = parent.children let index = childList.findIndex(item => { - return item === node + return item.uid === node.uid }) if (index === -1 || index === 0) { return @@ -580,7 +580,7 @@ class Render { let parent = node.parent let childList = parent.children let index = childList.findIndex(item => { - return item === node + return item.uid === node.uid }) if (index === -1 || index === childList.length - 1) { return @@ -752,7 +752,7 @@ class Render { let nodeParent = node.parent let nodeBorthers = nodeParent.children let nodeIndex = nodeBorthers.findIndex(item => { - return item === node + return item.uid === node.uid }) if (nodeIndex === -1) { return @@ -764,7 +764,7 @@ class Render { let existParent = exist.parent let existBorthers = existParent.children let existIndex = existBorthers.findIndex(item => { - return item === exist + return item.uid === exist.uid }) if (existIndex === -1) { return @@ -791,7 +791,7 @@ class Render { let nodeParent = node.parent let nodeBorthers = nodeParent.children let nodeIndex = nodeBorthers.findIndex(item => { - return item === node + return item.uid === node.uid }) if (nodeIndex === -1) { return @@ -803,7 +803,7 @@ class Render { let existParent = exist.parent let existBorthers = existParent.children let existIndex = existBorthers.findIndex(item => { - return item === exist + return item.uid === exist.uid }) if (existIndex === -1) { return diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index 9bca88b9..43e3075b 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -794,12 +794,12 @@ class Node { // 检测当前节点是否是某个节点的祖先节点 isParent(node) { - if (this === node) { + if (this.uid === node.uid) { return false } let parent = node.parent while (parent) { - if (this === parent) { + if (this.uid === parent.uid) { return true } parent = parent.parent @@ -809,11 +809,11 @@ class Node { // 检测当前节点是否是某个节点的兄弟节点 isBrother(node) { - if (!this.parent || this === node) { + if (!this.parent || this.uid === node.uid) { return false } return this.parent.children.find(item => { - return item === node + return item.uid === node.uid }) } diff --git a/simple-mind-map/src/plugins/AssociativeLine.js b/simple-mind-map/src/plugins/AssociativeLine.js index 7f0ae128..5855c27b 100644 --- a/simple-mind-map/src/plugins/AssociativeLine.js +++ b/simple-mind-map/src/plugins/AssociativeLine.js @@ -362,7 +362,7 @@ class AssociativeLine { if (node.nodeData.data.isActive) { this.mindMap.renderer.setNodeActive(node, false) } - if (node === this.creatingStartNode || this.overlapNode) { + if (node.uid === this.creatingStartNode.uid || this.overlapNode) { return } let { left, top, width, height } = node @@ -379,7 +379,7 @@ class AssociativeLine { // 完成创建连接线 completeCreateLine(node) { - if (this.creatingStartNode === node) return + if (this.creatingStartNode.uid === node.uid) return this.addLine(this.creatingStartNode, node) if (this.overlapNode && this.overlapNode.nodeData.data.isActive) { this.mindMap.renderer.setNodeActive(this.overlapNode, false) diff --git a/simple-mind-map/src/plugins/Drag.js b/simple-mind-map/src/plugins/Drag.js index fd99c5bf..3b49a035 100644 --- a/simple-mind-map/src/plugins/Drag.js +++ b/simple-mind-map/src/plugins/Drag.js @@ -218,7 +218,7 @@ class Drag extends Base { if (node.nodeData.data.isActive) { this.mindMap.renderer.setNodeActive(node, false) } - if (node === this.node || this.node.isParent(node)) { + if (node.uid === this.node.uid) { return } if (this.overlapNode || (this.prevNode && this.nextNode)) { @@ -231,7 +231,7 @@ class Drag extends Base { return item !== this.node }) : [] let index = checkList.findIndex((item) => { - return item === node + return item.uid === node.uid }) let prevBrother = null let nextBrother = null diff --git a/simple-mind-map/src/plugins/KeyboardNavigation.js b/simple-mind-map/src/plugins/KeyboardNavigation.js index 5ed4b593..d38815d0 100644 --- a/simple-mind-map/src/plugins/KeyboardNavigation.js +++ b/simple-mind-map/src/plugins/KeyboardNavigation.js @@ -94,7 +94,7 @@ class KeyboardNavigation { // 遍历节点树 bfsWalk(this.mindMap.renderer.root, node => { // 跳过当前聚焦的节点 - if (node === currentActiveNode) return + if (node.uid === currentActiveNode.uid) return // 当前遍历到的节点的位置信息 let rect = this.getNodeRect(node) let { left, top, right, bottom } = rect @@ -131,7 +131,7 @@ class KeyboardNavigation { checkNodeDis }) { bfsWalk(this.mindMap.renderer.root, node => { - if (node === currentActiveNode) return + if (node.uid === currentActiveNode.uid) return let rect = this.getNodeRect(node) let { left, top, right, bottom } = rect let match = false @@ -173,7 +173,7 @@ class KeyboardNavigation { let cX = (currentActiveNodeRect.right + currentActiveNodeRect.left) / 2 let cY = (currentActiveNodeRect.bottom + currentActiveNodeRect.top) / 2 bfsWalk(this.mindMap.renderer.root, node => { - if (node === currentActiveNode) return + if (node.uid === currentActiveNode.uid) return let rect = this.getNodeRect(node) let { left, top, right, bottom } = rect // 遍历到的节点的中心点 diff --git a/simple-mind-map/src/plugins/NodeImgAdjust.js b/simple-mind-map/src/plugins/NodeImgAdjust.js index cdde7045..ff62cb56 100644 --- a/simple-mind-map/src/plugins/NodeImgAdjust.js +++ b/simple-mind-map/src/plugins/NodeImgAdjust.js @@ -49,7 +49,7 @@ class NodeImgAdjust { // 如果当前正在拖动调整中那么直接返回 if (this.isMousedown || this.isAdjusted || this.mindMap.opt.readonly) return // 如果在当前节点内移动,以及自定义元素已经是显示状态,那么直接返回 - if (this.node === node && this.isShowHandleEl) return + if ((this.node && this.node.uid === node.uid) && this.isShowHandleEl) return // 更新当前节点信息 this.node = node this.img = img diff --git a/simple-mind-map/src/plugins/Painter.js b/simple-mind-map/src/plugins/Painter.js index b9ef5cd3..ff395165 100644 --- a/simple-mind-map/src/plugins/Painter.js +++ b/simple-mind-map/src/plugins/Painter.js @@ -49,7 +49,7 @@ class Painter { !this.isInPainter || !this.painterNode || !node || - node === this.painterNode + node.uid === this.painterNode.uid ) return const style = {}