Feat:节点移动结束事件node_dragend增加回调参数,可以获取到移动到节点的uid

This commit is contained in:
wanglin2 2023-08-02 19:05:15 +08:00
parent 0bdf9f3add
commit 803c83ac4f
5 changed files with 12 additions and 5 deletions

View File

@ -105,6 +105,9 @@ class Drag extends Base {
this.node.isDrag = false
this.node.show()
this.removeCloneNode()
let overlapNodeUid = this.overlapNode ? this.overlapNode.nodeData.data.uid : ''
let prevNodeUid = this.prevNode ? this.prevNode.nodeData.data.uid : ''
let nextNodeUid = this.nextNode ? this.nextNode.nodeData.data.uid : ''
// 存在重叠子节点,则移动作为其子节点
if (this.overlapNode) {
this.mindMap.renderer.setNodeActive(this.overlapNode, false)
@ -134,7 +137,11 @@ class Drag extends Base {
this.mindMap.render()
}
this.reset()
this.mindMap.emit('node_dragend')
this.mindMap.emit('node_dragend', {
overlapNodeUid,
prevNodeUid,
nextNodeUid
})
}
// 创建克隆节点

View File

@ -242,7 +242,7 @@ Listen to an event. Event list:
| rich_text_selection_changev0.4.0+ | Available when the `RichText` plugin is registered. Triggered when the text selection area changes when the node is edited | hasRangeWhether there is a selection、rectInfoSize and location information of the selected area、formatInfoText formatting information of the selected area |
| transforming-dom-to-imagesv0.4.0+ | Available when the `RichText` plugin is registered. When there is a `DOM` node in `svg`, the `DOM` node will be converted to an image when exporting to an image. This event will be triggered during the conversion process. You can use this event to prompt the user about the node to which you are currently converting | indexIndex of the node currently converted to、lenTotal number of nodes to be converted |
| node_draggingv0.4.5+ | Triggered when a node is dragged | node(The currently dragged node) |
| node_dragendv0.4.5+ | Triggered when the node is dragged and ends | |
| node_dragendv0.4.5+ | Triggered when the node is dragged and ends | { overlapNodeUid, prevNodeUid, nextNodeUid }v0.6.12+The node uid to which the node is moved this time, for example, if it is moved to node A, then the overlayNodeUid is the uid of node A. If it is moved to the front of node B, then the nextNodeUid is the uid of node B. You can obtain the node instance through the mindMap. extender.findNodeByUid(uid) method |
| associative_line_clickv0.4.5+ | Triggered when an associated line is clicked | path(Connector node)、clickPath(Invisible click line node)、node(Start node)、toNode(Target node) |
| svg_mouseenterv0.5.1+ | Triggered when the mouse moves into the SVG canvas | eevent object |
| svg_mouseleavev0.5.1+ | Triggered when the mouse moves out of the SVG canvas | eevent object |

View File

@ -697,7 +697,7 @@ poor performance and should be used sparingly.</p>
<tr>
<td>node_dragendv0.4.5+</td>
<td>Triggered when the node is dragged and ends</td>
<td></td>
<td>{ overlapNodeUid, prevNodeUid, nextNodeUid }v0.6.12+The node uid to which the node is moved this time, for example, if it is moved to node A, then the overlayNodeUid is the uid of node A. If it is moved to the front of node B, then the nextNodeUid is the uid of node B. You can obtain the node instance through the mindMap. extender.findNodeByUid(uid) method</td>
</tr>
<tr>
<td>associative_line_clickv0.4.5+</td>

View File

@ -237,7 +237,7 @@ mindMap.setTheme('主题名称')
| rich_text_selection_changev0.4.0+ | 当注册了`RichText`插件时可用。当节点编辑时,文本选区发生改变时触发 | hasRange是否存在选区、rectInfo选区的尺寸和位置信息、formatInfo选区的文本格式化信息 |
| transforming-dom-to-imagesv0.4.0+ | 当注册了`RichText`插件时可用。当`svg`中存在`DOM`节点时,导出为图片时会将`DOM`节点转换为图片,转换过程中会触发该事件,可用通过该事件给用户提示,告知目前转换到的节点 | index当前转换到的节点索引、len一共需要转换的节点数量 |
| node_draggingv0.4.5+ | 当某个节点被拖拽时触发 | node当前被拖拽的节点 |
| node_dragendv0.4.5+ | 节点被拖拽结束时触发 | |
| node_dragendv0.4.5+ | 节点被拖拽结束时触发 | { overlapNodeUid, prevNodeUid, nextNodeUid }v0.6.12+本次节点移动到的节点uid比如本次移动到了节点A上那么overlapNodeUid就是节点A的uid如果移动到了B节点的前面那么nextNodeUid就是节点B的uid你可以通过mindMap.renderer.findNodeByUid(uid)方法来获取节点实例) |
| associative_line_clickv0.4.5+ | 点击某条关联线时触发 | path连接线节点、clickPath不可见的点击线节点、node起始节点、toNode目标节点 |
| svg_mouseenterv0.5.1+ | 鼠标移入svg画布时触发 | e事件对象 |
| svg_mouseleavev0.5.1+ | 鼠标移出svg画布时触发 | e事件对象 |

View File

@ -690,7 +690,7 @@ mindMap.setTheme(<span class="hljs-string">&#x27;主题名称&#x27;</span>)
<tr>
<td>node_dragendv0.4.5+</td>
<td>节点被拖拽结束时触发</td>
<td></td>
<td>{ overlapNodeUid, prevNodeUid, nextNodeUid }v0.6.12+本次节点移动到的节点uid比如本次移动到了节点A上那么overlapNodeUid就是节点A的uid如果移动到了B节点的前面那么nextNodeUid就是节点B的uid你可以通过mindMap.renderer.findNodeByUid(uid)方法来获取节点实例</td>
</tr>
<tr>
<td>associative_line_clickv0.4.5+</td>