Fix:修复节点hover和激活节点时渲染的矩形会重叠的问题
This commit is contained in:
parent
c533459da1
commit
48f1de5c25
@ -46,7 +46,10 @@ class Base {
|
|||||||
|
|
||||||
// 检查当前来源是否需要重新计算节点大小
|
// 检查当前来源是否需要重新计算节点大小
|
||||||
checkIsNeedResizeSources() {
|
checkIsNeedResizeSources() {
|
||||||
return [CONSTANTS.CHANGE_THEME, CONSTANTS.TRANSFORM_TO_NORMAL_NODE].includes(this.renderer.renderSource)
|
return [
|
||||||
|
CONSTANTS.CHANGE_THEME,
|
||||||
|
CONSTANTS.TRANSFORM_TO_NORMAL_NODE
|
||||||
|
].includes(this.renderer.renderSource)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 层级类型改变
|
// 层级类型改变
|
||||||
@ -70,7 +73,10 @@ class Base {
|
|||||||
// 数据上保存了节点引用,那么直接复用节点
|
// 数据上保存了节点引用,那么直接复用节点
|
||||||
if (data && data._node && !this.renderer.reRender) {
|
if (data && data._node && !this.renderer.reRender) {
|
||||||
newNode = data._node
|
newNode = data._node
|
||||||
let isLayerTypeChange = this.checkIsLayerTypeChange(newNode.layerIndex, layerIndex)
|
let isLayerTypeChange = this.checkIsLayerTypeChange(
|
||||||
|
newNode.layerIndex,
|
||||||
|
layerIndex
|
||||||
|
)
|
||||||
newNode.reset()
|
newNode.reset()
|
||||||
newNode.layerIndex = layerIndex
|
newNode.layerIndex = layerIndex
|
||||||
this.cacheNode(data._node.uid, newNode)
|
this.cacheNode(data._node.uid, newNode)
|
||||||
@ -85,7 +91,10 @@ class Base {
|
|||||||
newNode = this.lru.get(data.data.uid)
|
newNode = this.lru.get(data.data.uid)
|
||||||
// 保存该节点上一次的数据
|
// 保存该节点上一次的数据
|
||||||
let lastData = JSON.stringify(newNode.nodeData.data)
|
let lastData = JSON.stringify(newNode.nodeData.data)
|
||||||
let isLayerTypeChange = this.checkIsLayerTypeChange(newNode.layerIndex, layerIndex)
|
let isLayerTypeChange = this.checkIsLayerTypeChange(
|
||||||
|
newNode.layerIndex,
|
||||||
|
layerIndex
|
||||||
|
)
|
||||||
newNode.reset()
|
newNode.reset()
|
||||||
newNode.nodeData = newNode.handleData(data || {})
|
newNode.nodeData = newNode.handleData(data || {})
|
||||||
newNode.layerIndex = layerIndex
|
newNode.layerIndex = layerIndex
|
||||||
@ -139,7 +148,7 @@ class Base {
|
|||||||
} else if (initRootNodePositionMap[value] !== undefined) {
|
} else if (initRootNodePositionMap[value] !== undefined) {
|
||||||
return size * initRootNodePositionMap[value]
|
return size * initRootNodePositionMap[value]
|
||||||
} else if (/^\d\d*%$/.test(value)) {
|
} else if (/^\d\d*%$/.test(value)) {
|
||||||
return Number.parseFloat(value) / 100 * size
|
return (Number.parseFloat(value) / 100) * size
|
||||||
} else {
|
} else {
|
||||||
return (size - nodeSize) / 2
|
return (size - nodeSize) / 2
|
||||||
}
|
}
|
||||||
@ -148,12 +157,24 @@ class Base {
|
|||||||
// 定位节点到画布中间
|
// 定位节点到画布中间
|
||||||
setNodeCenter(node) {
|
setNodeCenter(node) {
|
||||||
let { initRootNodePosition } = this.mindMap.opt
|
let { initRootNodePosition } = this.mindMap.opt
|
||||||
let { CENTER }= CONSTANTS.INIT_ROOT_NODE_POSITION
|
let { CENTER } = CONSTANTS.INIT_ROOT_NODE_POSITION
|
||||||
if (!initRootNodePosition || !Array.isArray(initRootNodePosition) || initRootNodePosition.length < 2) {
|
if (
|
||||||
|
!initRootNodePosition ||
|
||||||
|
!Array.isArray(initRootNodePosition) ||
|
||||||
|
initRootNodePosition.length < 2
|
||||||
|
) {
|
||||||
initRootNodePosition = [CENTER, CENTER]
|
initRootNodePosition = [CENTER, CENTER]
|
||||||
}
|
}
|
||||||
node.left = this.formatPosition(initRootNodePosition[0], this.mindMap.width, node.width)
|
node.left = this.formatPosition(
|
||||||
node.top = this.formatPosition(initRootNodePosition[1], this.mindMap.height, node.height)
|
initRootNodePosition[0],
|
||||||
|
this.mindMap.width,
|
||||||
|
node.width
|
||||||
|
)
|
||||||
|
node.top = this.formatPosition(
|
||||||
|
initRootNodePosition[1],
|
||||||
|
this.mindMap.height,
|
||||||
|
node.height
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新子节点属性
|
// 更新子节点属性
|
||||||
@ -170,7 +191,7 @@ class Base {
|
|||||||
// 更新子节点多个属性
|
// 更新子节点多个属性
|
||||||
updateChildrenPro(children, props) {
|
updateChildrenPro(children, props) {
|
||||||
children.forEach(item => {
|
children.forEach(item => {
|
||||||
Object.keys(props).forEach((prop) => {
|
Object.keys(props).forEach(prop => {
|
||||||
item[prop] += props[prop]
|
item[prop] += props[prop]
|
||||||
})
|
})
|
||||||
if (item.children && item.children.length && !item.hasCustomPosition()) {
|
if (item.children && item.children.length && !item.hasCustomPosition()) {
|
||||||
@ -216,16 +237,22 @@ class Base {
|
|||||||
|
|
||||||
// 获取节点的marginX
|
// 获取节点的marginX
|
||||||
getMarginX(layerIndex) {
|
getMarginX(layerIndex) {
|
||||||
|
const { themeConfig, opt } = this.mindMap
|
||||||
|
const { second, node } = themeConfig
|
||||||
|
const hoverRectPadding = opt.hoverRectPadding * 2
|
||||||
return layerIndex === 1
|
return layerIndex === 1
|
||||||
? this.mindMap.themeConfig.second.marginX
|
? second.marginX + hoverRectPadding
|
||||||
: this.mindMap.themeConfig.node.marginX
|
: node.marginX + hoverRectPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取节点的marginY
|
// 获取节点的marginY
|
||||||
getMarginY(layerIndex) {
|
getMarginY(layerIndex) {
|
||||||
|
const { themeConfig, opt } = this.mindMap
|
||||||
|
const { second, node } = themeConfig
|
||||||
|
const hoverRectPadding = opt.hoverRectPadding * 2
|
||||||
return layerIndex === 1
|
return layerIndex === 1
|
||||||
? this.mindMap.themeConfig.second.marginY
|
? second.marginY + hoverRectPadding
|
||||||
: this.mindMap.themeConfig.node.marginY
|
: node.marginY + hoverRectPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取节点包括概要在内的宽度
|
// 获取节点包括概要在内的宽度
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user