From 35894ecb4012ee98f91d8671407d654f7a0a172a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Wed, 23 Apr 2025 17:38:56 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E4=BC=98=E5=8C=96=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=8B=96=E6=8B=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/Drag.js | 41 +++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/simple-mind-map/src/plugins/Drag.js b/simple-mind-map/src/plugins/Drag.js index 643ca1ef..57215471 100644 --- a/simple-mind-map/src/plugins/Drag.js +++ b/simple-mind-map/src/plugins/Drag.js @@ -779,7 +779,7 @@ class Drag extends Base { checkList = checkList.reverse() } let oneFourthHeight = nodeRect.originHeight / 4 - let { prevBrotherOffset, nextBrotherOffset } = + let { prevBrother, prevBrotherOffset, nextBrother, nextBrotherOffset } = this.getNodeDistanceToSiblingNode(checkList, node, nodeRect, 'v') if (nodeRect.left <= mouseMoveX && nodeRect.right >= mouseMoveX) { // 检测兄弟节点位置 @@ -789,6 +789,25 @@ class Drag extends Base { !this.nextNode && !node.isRoot ) { + // 如果不在兄弟节点范围内,那么修改距离值 + if (prevBrother) { + const { scaleY } = this.drawTransform + const brotherRect = this.getNodeRect(prevBrother) + if ( + !(brotherRect.left <= mouseMoveX && brotherRect.right >= mouseMoveX) + ) { + prevBrotherOffset = this.minOffset * scaleY + } + } + if (nextBrother) { + const { scaleY } = this.drawTransform + const brotherRect = this.getNodeRect(nextBrother) + if ( + !(brotherRect.left <= mouseMoveX && brotherRect.right >= mouseMoveX) + ) { + nextBrotherOffset = this.minOffset * scaleY + } + } let checkIsPrevNode = nextBrotherOffset > 0 // 距离下一个兄弟节点的距离大于0 ? mouseMoveY > nodeRect.bottom && @@ -921,7 +940,7 @@ class Drag extends Base { let mouseMoveY = this.mouseMoveY let nodeRect = this.getNodeRect(node) let oneFourthWidth = nodeRect.originWidth / 4 - let { prevBrotherOffset, nextBrotherOffset } = + let { prevBrother, prevBrotherOffset, nextBrother, nextBrotherOffset } = this.getNodeDistanceToSiblingNode(checkList, node, nodeRect, 'h') if (nodeRect.top <= mouseMoveY && nodeRect.bottom >= mouseMoveY) { // 检测兄弟节点位置 @@ -931,6 +950,24 @@ class Drag extends Base { !this.nextNode && !node.isRoot ) { + if (prevBrother) { + const { scaleX } = this.drawTransform + const brotherRect = this.getNodeRect(prevBrother) + if ( + !(brotherRect.top <= mouseMoveY && brotherRect.bottom >= mouseMoveY) + ) { + prevBrotherOffset = this.minOffset * scaleX + } + } + if (nextBrother) { + const { scaleX } = this.drawTransform + const brotherRect = this.getNodeRect(nextBrother) + if ( + !(brotherRect.top <= mouseMoveY && brotherRect.bottom >= mouseMoveY) + ) { + nextBrotherOffset = this.minOffset * scaleX + } + } let checkIsPrevNode = nextBrotherOffset > 0 // 距离下一个兄弟节点的距离大于0 ? mouseMoveX < nodeRect.right + nextBrotherOffset &&