Feat:新增禁止拖动画布的配置选项

This commit is contained in:
wanglin2 2023-11-20 11:39:08 +08:00
parent ffc7bf5b7e
commit a1ec72b401
2 changed files with 7 additions and 3 deletions

View File

@ -219,5 +219,7 @@ export const defaultOpt = {
// 可以传递一个函数返回promiseresolve代表根据换行分割reject代表忽略换行
handleIsSplitByWrapOnPasteCreateNewNode: null,
// 多少时间内只允许添加一次历史记录避免添加没有必要的中间状态单位ms
addHistoryTime: 100
addHistoryTime: 100,
// 是否禁止拖动画布
isDisableDrag: false
}

View File

@ -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) {