Feat:优化鼠标按下节点事件逻辑,在右键拖拽画布模式下支持右键按住根节点拖拽画布
This commit is contained in:
parent
7f9d03c8af
commit
29bb27aa23
@ -182,5 +182,9 @@ export const defaultOpt = {
|
|||||||
// 节点鼠标hover和激活时显示的矩形边框距节点内容的距离
|
// 节点鼠标hover和激活时显示的矩形边框距节点内容的距离
|
||||||
hoverRectPadding: 2,
|
hoverRectPadding: 2,
|
||||||
// 双击节点进入节点文本编辑时是否默认选中文本,默认只在创建新节点时会选中
|
// 双击节点进入节点文本编辑时是否默认选中文本,默认只在创建新节点时会选中
|
||||||
selectTextOnEnterEditText: false
|
selectTextOnEnterEditText: false,
|
||||||
|
// 拖拽模式
|
||||||
|
// default:按住画布、根节点都可拖拽画布
|
||||||
|
// noCanvas:按住根节点和
|
||||||
|
dragMode: ''
|
||||||
}
|
}
|
||||||
|
|||||||
@ -394,14 +394,23 @@ class Node {
|
|||||||
this.active(e)
|
this.active(e)
|
||||||
})
|
})
|
||||||
this.group.on('mousedown', e => {
|
this.group.on('mousedown', e => {
|
||||||
if (this.isRoot && e.which === 3 && !this.mindMap.opt.readonly) {
|
const { readonly, enableCtrlKeyNodeSelection, useLeftKeySelectionRightKeyDrag } = this.mindMap.opt
|
||||||
e.stopPropagation()
|
// 只读模式不需要阻止冒泡
|
||||||
}
|
if (!readonly) {
|
||||||
if (!this.isRoot && e.which !== 2 && !this.mindMap.opt.readonly) {
|
if (this.isRoot) {
|
||||||
e.stopPropagation()
|
// 根节点,右键拖拽画布模式下不需要阻止冒泡
|
||||||
|
if (e.which === 3 && !useLeftKeySelectionRightKeyDrag) {
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 非根节点,且按下的是非鼠标中键,需要阻止事件冒泡
|
||||||
|
if (e.which !== 2) {
|
||||||
|
e.stopPropagation()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 多选和取消多选
|
// 多选和取消多选
|
||||||
if (e.ctrlKey && this.mindMap.opt.enableCtrlKeyNodeSelection) {
|
if (e.ctrlKey && enableCtrlKeyNodeSelection) {
|
||||||
this.isMultipleChoice = true
|
this.isMultipleChoice = true
|
||||||
let isActive = this.nodeData.data.isActive
|
let isActive = this.nodeData.data.isActive
|
||||||
if (!isActive)
|
if (!isActive)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user