From fd0c471f0053be15b0546eb9f0dbbe296a8730ef Mon Sep 17 00:00:00 2001 From: wanglin <1013335014@qq.com> Date: Tue, 13 Jul 2021 08:04:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/Select.js | 27 +++++++++++++++++++++++++-- simple-mind-map/src/View.js | 9 +++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/simple-mind-map/src/Select.js b/simple-mind-map/src/Select.js index 2308dc3a..e7776013 100644 --- a/simple-mind-map/src/Select.js +++ b/simple-mind-map/src/Select.js @@ -44,8 +44,9 @@ class Select { if (!this.isMousedown) { return } - this.mouseMoveX = e.clientX - this.mouseMoveY = e.clientY + let { x, y } = this.toPos(e.clientX, e.clientY) + this.mouseMoveX = x + this.mouseMoveY = y this.rect.plot([ [this.mouseDownX, this.mouseDownY], [this.mouseMoveX, this.mouseDownY], @@ -53,6 +54,7 @@ class Select { [this.mouseDownX, this.mouseMoveY] ]) this.checkInNodes() + this.move(x, y) }) this.mindMap.on('mouseup', (e) => { if (!this.isMousedown) { @@ -65,6 +67,21 @@ class Select { }) } + /** + * @Author: 王林 + * @Date: 2021-07-13 07:55:49 + * @Desc: 鼠标移动到边缘后移动画布 + */ + move (x, y) { + if (x >= this.mindMap.elRect.right - 20) { + console.log('小于') + } + if (y >= this.mindMap.elRect.bottom - 20) { + console.log('小于') + this.mindMap.view.translateY(-3) + } + } + /** * @Author: 王林 * @Date: 2021-07-11 10:19:37 @@ -114,11 +131,17 @@ class Select { bottom <= maxy ) { this.mindMap.batchExecution.push('activeNode' + node.uid, () => { + if (node.nodeData.data.isActive) { + return ; + } this.mindMap.execCommand('SET_NODE_ACTIVE', node, true) this.mindMap.renderer.addActiveNode(node) }) } else if (node.nodeData.data.isActive) { this.mindMap.batchExecution.push('activeNode' + node.uid, () => { + if (!node.nodeData.data.isActive) { + return ; + } this.mindMap.execCommand('SET_NODE_ACTIVE', node, false) this.mindMap.renderer.removeActiveNode(node) }) diff --git a/simple-mind-map/src/View.js b/simple-mind-map/src/View.js index 3fb62b79..f20e55bb 100644 --- a/simple-mind-map/src/View.js +++ b/simple-mind-map/src/View.js @@ -60,6 +60,15 @@ class View { }) } + translateX() { + + } + + translateY(step) { + this.y += step + this.transform() + } + /** * @Author: 王林 * @Date: 2021-07-04 17:13:14