Fix:修复多选节点时选区未包含节点边界时节点不会被选中的问题
This commit is contained in:
parent
977799a3ac
commit
740e2e3410
@ -1,4 +1,4 @@
|
|||||||
import { bfsWalk, throttle } from '../utils'
|
import { bfsWalk, throttle, checkTwoRectIsOverlap } from '../utils'
|
||||||
|
|
||||||
// 节点选择插件
|
// 节点选择插件
|
||||||
class Select {
|
class Select {
|
||||||
@ -210,24 +210,19 @@ class Select {
|
|||||||
left = left * scaleX + translateX
|
left = left * scaleX + translateX
|
||||||
top = top * scaleY + translateY
|
top = top * scaleY + translateY
|
||||||
if (
|
if (
|
||||||
((left >= minx && left <= maxx) || (right >= minx && right <= maxx)) &&
|
checkTwoRectIsOverlap(minx, maxx, miny, maxy, left, right, top, bottom)
|
||||||
((top >= miny && top <= maxy) || (bottom >= miny && bottom <= maxy))
|
|
||||||
) {
|
) {
|
||||||
// this.mindMap.batchExecution.push('activeNode' + node.uid, () => {
|
|
||||||
if (node.nodeData.data.isActive) {
|
if (node.nodeData.data.isActive) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.mindMap.renderer.setNodeActive(node, true)
|
this.mindMap.renderer.setNodeActive(node, true)
|
||||||
this.mindMap.renderer.addActiveNode(node)
|
this.mindMap.renderer.addActiveNode(node)
|
||||||
// })
|
|
||||||
} else if (node.nodeData.data.isActive) {
|
} else if (node.nodeData.data.isActive) {
|
||||||
// this.mindMap.batchExecution.push('activeNode' + node.uid, () => {
|
|
||||||
if (!node.nodeData.data.isActive) {
|
if (!node.nodeData.data.isActive) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.mindMap.renderer.setNodeActive(node, false)
|
this.mindMap.renderer.setNodeActive(node, false)
|
||||||
this.mindMap.renderer.removeActiveNode(node)
|
this.mindMap.renderer.removeActiveNode(node)
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -669,3 +669,32 @@ export const checkIsNodeStyleDataKey = key => {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 从节点实例列表里找出顶层的节点
|
||||||
|
export const getTopAncestorsFomNodeList = list => {
|
||||||
|
let res = []
|
||||||
|
list.forEach(node => {
|
||||||
|
if (
|
||||||
|
!list.find(item => {
|
||||||
|
return item.uid !== node.uid && item.isParent(node)
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
res.push(node)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断两个矩形是否重叠
|
||||||
|
export const checkTwoRectIsOverlap = (
|
||||||
|
minx1,
|
||||||
|
maxx1,
|
||||||
|
miny1,
|
||||||
|
maxy1,
|
||||||
|
minx2,
|
||||||
|
maxx2,
|
||||||
|
miny2,
|
||||||
|
maxy2
|
||||||
|
) => {
|
||||||
|
return maxx1 > minx2 && maxx2 > minx1 && maxy1 > miny2 && maxy2 > miny1
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user