From a1ec72b4017a82285b5fd4db90a37aa1de09b7ac Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Mon, 20 Nov 2023 11:39:08 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E7=A6=81?= =?UTF-8?q?=E6=AD=A2=E6=8B=96=E5=8A=A8=E7=94=BB=E5=B8=83=E7=9A=84=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/constants/defaultOptions.js | 4 +++- simple-mind-map/src/core/view/View.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index d658fc83..08c73308 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -219,5 +219,7 @@ export const defaultOpt = { // 可以传递一个函数,返回promise,resolve代表根据换行分割,reject代表忽略换行 handleIsSplitByWrapOnPasteCreateNewNode: null, // 多少时间内只允许添加一次历史记录,避免添加没有必要的中间状态,单位:ms - addHistoryTime: 100 + addHistoryTime: 100, + // 是否禁止拖动画布 + isDisableDrag: false } diff --git a/simple-mind-map/src/core/view/View.js b/simple-mind-map/src/core/view/View.js index 853f9d14..df580b1b 100644 --- a/simple-mind-map/src/core/view/View.js +++ b/simple-mind-map/src/core/view/View.js @@ -30,12 +30,14 @@ class View { }) // 拖动视图 this.mindMap.event.on('mousedown', () => { + if (this.mindMap.opt.isDisableDrag) return this.sx = this.x this.sy = this.y }) this.mindMap.event.on('drag', (e, event) => { - if (e.ctrlKey) { - // 按住ctrl键拖动为多选 + // 按住ctrl键拖动为多选 + // 禁用拖拽 + if (e.ctrlKey || this.mindMap.opt.isDisableDrag) { return } if (this.firstDrag) {