Fix:修复拖拽画布时鼠标在节点上面松开时拖拽无法停止的问题

This commit is contained in:
街角小林 2023-12-21 10:32:45 +08:00
parent abc30da43b
commit 4d9aa1d3c2

View File

@ -34,6 +34,7 @@ class Event extends EventEmitter {
this.onMousedown = this.onMousedown.bind(this)
this.onMousemove = this.onMousemove.bind(this)
this.onMouseup = this.onMouseup.bind(this)
this.onNodeMouseup = this.onNodeMouseup.bind(this)
this.onMousewheel = this.onMousewheel.bind(this)
this.onContextmenu = this.onContextmenu.bind(this)
this.onSvgMousedown = this.onSvgMousedown.bind(this)
@ -50,6 +51,7 @@ class Event extends EventEmitter {
this.mindMap.svg.on('mousedown', this.onSvgMousedown)
window.addEventListener('mousemove', this.onMousemove)
window.addEventListener('mouseup', this.onMouseup)
this.on('node_mouseup', this.onNodeMouseup)
this.mindMap.el.addEventListener('wheel', this.onMousewheel)
this.mindMap.svg.on('contextmenu', this.onContextmenu)
this.mindMap.svg.on('mouseenter', this.onMouseenter)
@ -64,6 +66,7 @@ class Event extends EventEmitter {
this.mindMap.el.removeEventListener('mousedown', this.onMousedown)
window.removeEventListener('mousemove', this.onMousemove)
window.removeEventListener('mouseup', this.onMouseup)
this.off('node_mouseup', this.onNodeMouseup)
this.mindMap.el.removeEventListener('wheel', this.onMousewheel)
this.mindMap.svg.off('contextmenu', this.onContextmenu)
this.mindMap.svg.off('mouseenter', this.onMouseenter)
@ -122,10 +125,15 @@ class Event extends EventEmitter {
// 鼠标松开事件
onMouseup(e) {
this.onNodeMouseup()
this.emit('mouseup', e, this)
}
// 节点鼠标松开事件
onNodeMouseup() {
this.isLeftMousedown = false
this.isRightMousedown = false
this.isMiddleMousedown = false
this.emit('mouseup', e, this)
}
// 鼠标滚动/触控板滑动