Fix:优化Select插件,如果多选节点没有变化,那么不触发激活激活事件
This commit is contained in:
parent
1157257911
commit
6b4c118a2b
@ -12,6 +12,7 @@ class Select {
|
|||||||
this.mouseMoveX = 0
|
this.mouseMoveX = 0
|
||||||
this.mouseMoveY = 0
|
this.mouseMoveY = 0
|
||||||
this.isSelecting = false
|
this.isSelecting = false
|
||||||
|
this.cacheActiveList = []
|
||||||
this.bindEvent()
|
this.bindEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ class Select {
|
|||||||
}
|
}
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
this.isMousedown = true
|
this.isMousedown = true
|
||||||
|
this.cacheActiveList = [...this.mindMap.renderer.activeNodeList]
|
||||||
let { x, y } = this.mindMap.toPos(e.clientX, e.clientY)
|
let { x, y } = this.mindMap.toPos(e.clientX, e.clientY)
|
||||||
this.mouseDownX = x
|
this.mouseDownX = x
|
||||||
this.mouseDownY = y
|
this.mouseDownY = y
|
||||||
@ -62,13 +64,10 @@ class Select {
|
|||||||
if (!this.isMousedown) {
|
if (!this.isMousedown) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.mindMap.emit(
|
this.checkTriggerNodeActiveEvent()
|
||||||
'node_active',
|
|
||||||
null,
|
|
||||||
this.mindMap.renderer.activeNodeList
|
|
||||||
)
|
|
||||||
clearTimeout(this.autoMoveTimer)
|
clearTimeout(this.autoMoveTimer)
|
||||||
this.isMousedown = false
|
this.isMousedown = false
|
||||||
|
this.cacheActiveList = []
|
||||||
if (this.rect) this.rect.remove()
|
if (this.rect) this.rect.remove()
|
||||||
this.rect = null
|
this.rect = null
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -77,6 +76,30 @@ class Select {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果激活节点改变了,那么触发事件
|
||||||
|
checkTriggerNodeActiveEvent() {
|
||||||
|
let isNumChange = this.cacheActiveList.length !== this.mindMap.renderer.activeNodeList.length
|
||||||
|
let isNodeChange = false
|
||||||
|
if (!isNumChange) {
|
||||||
|
for(let i = 0; i < this.cacheActiveList.length; i++) {
|
||||||
|
let cur = this.cacheActiveList[i]
|
||||||
|
if (!this.mindMap.renderer.activeNodeList.find((item) => {
|
||||||
|
return item.nodeData.data.uid === cur.nodeData.data.uid
|
||||||
|
})){
|
||||||
|
isNodeChange = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isNumChange || isNodeChange) {
|
||||||
|
this.mindMap.emit(
|
||||||
|
'node_active',
|
||||||
|
null,
|
||||||
|
this.mindMap.renderer.activeNodeList
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 鼠标移动事件
|
// 鼠标移动事件
|
||||||
onMove(x, y) {
|
onMove(x, y) {
|
||||||
this.isSelecting = true
|
this.isSelecting = true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user