Feat:新增拦截节点开始拖拽的实例化选项
This commit is contained in:
parent
1ec723db0e
commit
a047dabbd0
@ -256,6 +256,8 @@ export const defaultOpt = {
|
|||||||
handleDragCloneNode: null,
|
handleDragCloneNode: null,
|
||||||
// 即将拖拽完成前调用该函数,函数接收一个对象作为参数:{overlapNodeUid,prevNodeUid,nextNodeUid},代表拖拽信息,如果要阻止本次拖拽,那么可以返回true,此时node_dragend事件不会再触发。函数可以是异步函数,返回Promise实例
|
// 即将拖拽完成前调用该函数,函数接收一个对象作为参数:{overlapNodeUid,prevNodeUid,nextNodeUid},代表拖拽信息,如果要阻止本次拖拽,那么可以返回true,此时node_dragend事件不会再触发。函数可以是异步函数,返回Promise实例
|
||||||
beforeDragEnd: null,
|
beforeDragEnd: null,
|
||||||
|
// 即将开始调整节点前调用该函数,函数接收当前即将被拖拽的节点实例列表作为参数,如果要阻止本次拖拽,那么可以返回true
|
||||||
|
beforeDragStart: null,
|
||||||
|
|
||||||
// 【Watermark插件】
|
// 【Watermark插件】
|
||||||
// 水印配置
|
// 水印配置
|
||||||
@ -380,5 +382,5 @@ export const defaultOpt = {
|
|||||||
beforeHideRichTextEdit: null,
|
beforeHideRichTextEdit: null,
|
||||||
// 设置富文本节点编辑框和节点大小一致,形成伪原地编辑的效果
|
// 设置富文本节点编辑框和节点大小一致,形成伪原地编辑的效果
|
||||||
// 需要注意的是,只有当节点内只有文本、且形状是矩形才会有比较好的效果
|
// 需要注意的是,只有当节点内只有文本、且形状是矩形才会有比较好的效果
|
||||||
richTextEditFakeInPlace: false,
|
richTextEditFakeInPlace: false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ class Drag extends Base {
|
|||||||
|
|
||||||
// 复位
|
// 复位
|
||||||
reset() {
|
reset() {
|
||||||
// 是否正在跳转中
|
// 是否正在拖拽中
|
||||||
this.isDragging = false
|
this.isDragging = false
|
||||||
// 鼠标按下的节点
|
// 鼠标按下的节点
|
||||||
this.mousedownNode = null
|
this.mousedownNode = null
|
||||||
@ -223,7 +223,7 @@ class Drag extends Base {
|
|||||||
|
|
||||||
// 拖动中
|
// 拖动中
|
||||||
onMove(x, y, e) {
|
onMove(x, y, e) {
|
||||||
if (!this.isMousedown) {
|
if (!this.isMousedown || !this.isDragging) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 更新克隆节点的位置
|
// 更新克隆节点的位置
|
||||||
@ -245,9 +245,8 @@ class Drag extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 开始拖拽时初始化一些数据
|
// 开始拖拽时初始化一些数据
|
||||||
handleStartMove() {
|
async handleStartMove() {
|
||||||
if (!this.isDragging) {
|
if (!this.isDragging) {
|
||||||
this.isDragging = true
|
|
||||||
// 鼠标按下的节点
|
// 鼠标按下的节点
|
||||||
let node = this.mousedownNode
|
let node = this.mousedownNode
|
||||||
// 计算鼠标按下的位置距离节点左上角的距离
|
// 计算鼠标按下的位置距离节点左上角的距离
|
||||||
@ -268,12 +267,19 @@ class Drag extends Base {
|
|||||||
// 否则只拖拽按下的节点
|
// 否则只拖拽按下的节点
|
||||||
this.beingDragNodeList = [node]
|
this.beingDragNodeList = [node]
|
||||||
}
|
}
|
||||||
|
// 拦截拖拽
|
||||||
|
const { beforeDragStart } = this.mindMap.opt
|
||||||
|
if (typeof beforeDragStart === 'function') {
|
||||||
|
const stop = await beforeDragStart([...this.beingDragNodeList])
|
||||||
|
if (stop) return
|
||||||
|
}
|
||||||
// 将节点树转为节点数组
|
// 将节点树转为节点数组
|
||||||
this.nodeTreeToList()
|
this.nodeTreeToList()
|
||||||
// 创建克隆节点
|
// 创建克隆节点
|
||||||
this.createCloneNode()
|
this.createCloneNode()
|
||||||
// 清除当前所有激活的节点
|
// 清除当前所有激活的节点
|
||||||
this.mindMap.execCommand('CLEAR_ACTIVE_NODE')
|
this.mindMap.execCommand('CLEAR_ACTIVE_NODE')
|
||||||
|
this.isDragging = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user