Fix:修复除了向右生长的结构,其他结构鼠标移入展开收起按钮位置时不会触发按钮显示的问题
This commit is contained in:
parent
ad0f62a5ac
commit
eaa8929457
@ -275,7 +275,8 @@ class Node {
|
|||||||
}
|
}
|
||||||
this._unVisibleRectRegionNode.fill({
|
this._unVisibleRectRegionNode.fill({
|
||||||
color: 'transparent'
|
color: 'transparent'
|
||||||
}).size(this.expandBtnSize, height).x(width).y(0)
|
})
|
||||||
|
this.renderer.layout.renderExpandBtnRect(this._unVisibleRectRegionNode, this.expandBtnSize, width, height, this)
|
||||||
this.group.add(this._unVisibleRectRegionNode)
|
this.group.add(this._unVisibleRectRegionNode)
|
||||||
}
|
}
|
||||||
// 概要节点添加一个带所属节点id的类名
|
// 概要节点添加一个带所属节点id的类名
|
||||||
@ -289,7 +290,7 @@ class Node {
|
|||||||
foreignObject.height(height)
|
foreignObject.height(height)
|
||||||
foreignObject.add(SVG(this._customNodeContent))
|
foreignObject.add(SVG(this._customNodeContent))
|
||||||
this.group.add(foreignObject)
|
this.group.add(foreignObject)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 图片节点
|
// 图片节点
|
||||||
let imgHeight = 0
|
let imgHeight = 0
|
||||||
@ -433,7 +434,8 @@ class Node {
|
|||||||
// 右键菜单事件
|
// 右键菜单事件
|
||||||
this.group.on('contextmenu', e => {
|
this.group.on('contextmenu', e => {
|
||||||
// 按住ctrl键点击鼠标左键不知为何触发的是contextmenu事件
|
// 按住ctrl键点击鼠标左键不知为何触发的是contextmenu事件
|
||||||
if (this.mindMap.opt.readonly || e.ctrlKey) {// || this.isGeneralization
|
if (this.mindMap.opt.readonly || e.ctrlKey) {
|
||||||
|
// || this.isGeneralization
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
@ -467,8 +469,11 @@ class Node {
|
|||||||
if (!this.group) {
|
if (!this.group) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let { enableNodeTransitionMove, nodeTransitionMoveDuration, alwaysShowExpandBtn } =
|
let {
|
||||||
this.mindMap.opt
|
enableNodeTransitionMove,
|
||||||
|
nodeTransitionMoveDuration,
|
||||||
|
alwaysShowExpandBtn
|
||||||
|
} = this.mindMap.opt
|
||||||
if (alwaysShowExpandBtn) {
|
if (alwaysShowExpandBtn) {
|
||||||
// 需要移除展开收缩按钮
|
// 需要移除展开收缩按钮
|
||||||
if (this._expandBtn && this.nodeData.children.length <= 0) {
|
if (this._expandBtn && this.nodeData.children.length <= 0) {
|
||||||
@ -783,7 +788,7 @@ class Node {
|
|||||||
|
|
||||||
// 获取padding值
|
// 获取padding值
|
||||||
getPaddingVale() {
|
getPaddingVale() {
|
||||||
let { isActive }= this.nodeData.data
|
let { isActive } = this.nodeData.data
|
||||||
return {
|
return {
|
||||||
paddingX: this.getStyle('paddingX', true, isActive),
|
paddingX: this.getStyle('paddingX', true, isActive),
|
||||||
paddingY: this.getStyle('paddingY', true, isActive)
|
paddingY: this.getStyle('paddingY', true, isActive)
|
||||||
|
|||||||
@ -349,6 +349,11 @@ class CatalogOrganization extends Base {
|
|||||||
gNode.left = right + generalizationNodeMargin
|
gNode.left = right + generalizationNodeMargin
|
||||||
gNode.top = top + (bottom - top - gNode.height) / 2
|
gNode.top = top + (bottom - top - gNode.height) / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 渲染展开收起按钮的隐藏占位元素
|
||||||
|
renderExpandBtnRect(rect, expandBtnSize, width, height, node) {
|
||||||
|
rect.size(width, expandBtnSize).x(0).y(height)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CatalogOrganization
|
export default CatalogOrganization
|
||||||
|
|||||||
@ -239,7 +239,7 @@ class Fishbone extends Base {
|
|||||||
// 当前节点是根节点
|
// 当前节点是根节点
|
||||||
// 根节点的子节点是和根节点同一水平线排列
|
// 根节点的子节点是和根节点同一水平线排列
|
||||||
let maxx = -Infinity
|
let maxx = -Infinity
|
||||||
node.children.forEach((item) => {
|
node.children.forEach(item => {
|
||||||
if (item.left > maxx) {
|
if (item.left > maxx) {
|
||||||
maxx = item.left
|
maxx = item.left
|
||||||
}
|
}
|
||||||
@ -250,15 +250,15 @@ class Fishbone extends Base {
|
|||||||
let line = this.draw.path()
|
let line = this.draw.path()
|
||||||
if (this.checkIsTop(item)) {
|
if (this.checkIsTop(item)) {
|
||||||
line.plot(
|
line.plot(
|
||||||
`M ${nodeLineX - offsetX},${item.top + item.height + offset} L ${item.left},${
|
`M ${nodeLineX - offsetX},${item.top + item.height + offset} L ${
|
||||||
item.top + item.height
|
item.left
|
||||||
}`
|
},${item.top + item.height}`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
line.plot(
|
line.plot(
|
||||||
`M ${nodeLineX - offsetX},${
|
`M ${nodeLineX - offsetX},${item.top - offset} L ${nodeLineX},${
|
||||||
item.top - offset
|
item.top
|
||||||
} L ${nodeLineX},${item.top}`
|
}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
node.style.line(line)
|
node.style.line(line)
|
||||||
@ -373,6 +373,27 @@ class Fishbone extends Base {
|
|||||||
gNode.left = right + generalizationNodeMargin
|
gNode.left = right + generalizationNodeMargin
|
||||||
gNode.top = top + (bottom - top - gNode.height) / 2
|
gNode.top = top + (bottom - top - gNode.height) / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 渲染展开收起按钮的隐藏占位元素
|
||||||
|
renderExpandBtnRect(rect, expandBtnSize, width, height, node) {
|
||||||
|
let dir = ''
|
||||||
|
if (node.dir === CONSTANTS.LAYOUT_GROW_DIR.TOP) {
|
||||||
|
dir =
|
||||||
|
node.layerIndex === 1
|
||||||
|
? CONSTANTS.LAYOUT_GROW_DIR.TOP
|
||||||
|
: CONSTANTS.LAYOUT_GROW_DIR.BOTTOM
|
||||||
|
} else {
|
||||||
|
dir =
|
||||||
|
node.layerIndex === 1
|
||||||
|
? CONSTANTS.LAYOUT_GROW_DIR.BOTTOM
|
||||||
|
: CONSTANTS.LAYOUT_GROW_DIR.TOP
|
||||||
|
}
|
||||||
|
if (dir === CONSTANTS.LAYOUT_GROW_DIR.TOP) {
|
||||||
|
rect.size(width, expandBtnSize).x(0).y(-expandBtnSize)
|
||||||
|
} else {
|
||||||
|
rect.size(width, expandBtnSize).x(0).y(height)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Fishbone
|
export default Fishbone
|
||||||
|
|||||||
@ -172,9 +172,7 @@ class LogicalStructure extends Base {
|
|||||||
let x2 = item.left
|
let x2 = item.left
|
||||||
let y2 = item.top + item.height / 2
|
let y2 = item.top + item.height / 2
|
||||||
// 节点使用横线风格,需要额外渲染横线
|
// 节点使用横线风格,需要额外渲染横线
|
||||||
let nodeUseLineStyleOffset = nodeUseLineStyle
|
let nodeUseLineStyleOffset = nodeUseLineStyle ? item.width : 0
|
||||||
? item.width
|
|
||||||
: 0
|
|
||||||
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
|
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
|
||||||
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
|
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
|
||||||
let path = `M ${x1},${y1} L ${x1 + s1},${y1} L ${x1 + s1},${y2} L ${
|
let path = `M ${x1},${y1} L ${x1 + s1},${y1} L ${x1 + s1},${y2} L ${
|
||||||
@ -260,10 +258,7 @@ class LogicalStructure extends Base {
|
|||||||
if (_x === translateX && _y === translateY) {
|
if (_x === translateX && _y === translateY) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
btn.translate(
|
btn.translate(_x - translateX, _y - translateY)
|
||||||
_x - translateX,
|
|
||||||
_y - translateY
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建概要节点
|
// 创建概要节点
|
||||||
@ -286,6 +281,11 @@ class LogicalStructure extends Base {
|
|||||||
gNode.left = right + generalizationNodeMargin
|
gNode.left = right + generalizationNodeMargin
|
||||||
gNode.top = top + (bottom - top - gNode.height) / 2
|
gNode.top = top + (bottom - top - gNode.height) / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 渲染展开收起按钮的隐藏占位元素
|
||||||
|
renderExpandBtnRect(rect, expandBtnSize, width, height, node) {
|
||||||
|
rect.size(expandBtnSize, height).x(width).y(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default LogicalStructure
|
export default LogicalStructure
|
||||||
|
|||||||
@ -46,7 +46,10 @@ class MindMap extends Base {
|
|||||||
newNode.dir = parent._node.dir
|
newNode.dir = parent._node.dir
|
||||||
} else {
|
} else {
|
||||||
// 节点生长方向
|
// 节点生长方向
|
||||||
newNode.dir = index % 2 === 0 ? CONSTANTS.LAYOUT_GROW_DIR.RIGHT : CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
newNode.dir =
|
||||||
|
index % 2 === 0
|
||||||
|
? CONSTANTS.LAYOUT_GROW_DIR.RIGHT
|
||||||
|
: CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
||||||
}
|
}
|
||||||
// 根据生长方向定位到父节点的左侧或右侧
|
// 根据生长方向定位到父节点的左侧或右侧
|
||||||
newNode.left =
|
newNode.left =
|
||||||
@ -163,7 +166,10 @@ class MindMap extends Base {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
let _offset = 0
|
let _offset = 0
|
||||||
let addHeight = item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT ? leftAddHeight : rightAddHeight
|
let addHeight =
|
||||||
|
item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
||||||
|
? leftAddHeight
|
||||||
|
: rightAddHeight
|
||||||
// 上面的节点往上移
|
// 上面的节点往上移
|
||||||
if (_index < index) {
|
if (_index < index) {
|
||||||
_offset = -addHeight
|
_offset = -addHeight
|
||||||
@ -209,9 +215,7 @@ class MindMap extends Base {
|
|||||||
let x1 = 0
|
let x1 = 0
|
||||||
let _s = 0
|
let _s = 0
|
||||||
// 节点使用横线风格,需要额外渲染横线
|
// 节点使用横线风格,需要额外渲染横线
|
||||||
let nodeUseLineStyleOffset = nodeUseLineStyle
|
let nodeUseLineStyleOffset = nodeUseLineStyle ? item.width : 0
|
||||||
? item.width
|
|
||||||
: 0
|
|
||||||
if (item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT) {
|
if (item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT) {
|
||||||
_s = -s1
|
_s = -s1
|
||||||
x1 = node.layerIndex === 0 ? left : left - expandBtnSize
|
x1 = node.layerIndex === 0 ? left : left - expandBtnSize
|
||||||
@ -221,7 +225,10 @@ class MindMap extends Base {
|
|||||||
x1 = node.layerIndex === 0 ? left + width : left + width + expandBtnSize
|
x1 = node.layerIndex === 0 ? left + width : left + width + expandBtnSize
|
||||||
}
|
}
|
||||||
let y1 = top + height / 2
|
let y1 = top + height / 2
|
||||||
let x2 = item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT ? item.left + item.width : item.left
|
let x2 =
|
||||||
|
item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
||||||
|
? item.left + item.width
|
||||||
|
: item.left
|
||||||
let y2 = item.top + item.height / 2
|
let y2 = item.top + item.height / 2
|
||||||
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
|
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
|
||||||
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
|
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
|
||||||
@ -251,7 +258,10 @@ class MindMap extends Base {
|
|||||||
? left - expandBtnSize
|
? left - expandBtnSize
|
||||||
: left + width + expandBtnSize
|
: left + width + expandBtnSize
|
||||||
let y1 = top + height / 2
|
let y1 = top + height / 2
|
||||||
let x2 = item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT ? item.left + item.width : item.left
|
let x2 =
|
||||||
|
item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
||||||
|
? item.left + item.width
|
||||||
|
: item.left
|
||||||
let y2 = item.top + item.height / 2
|
let y2 = item.top + item.height / 2
|
||||||
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
|
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
|
||||||
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
|
y2 = nodeUseLineStyle ? y2 + item.height / 2 : y2
|
||||||
@ -288,7 +298,10 @@ class MindMap extends Base {
|
|||||||
? left - expandBtnSize
|
? left - expandBtnSize
|
||||||
: left + width + expandBtnSize
|
: left + width + expandBtnSize
|
||||||
let y1 = top + height / 2
|
let y1 = top + height / 2
|
||||||
let x2 = item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT ? item.left + item.width : item.left
|
let x2 =
|
||||||
|
item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
||||||
|
? item.left + item.width
|
||||||
|
: item.left
|
||||||
let y2 = item.top + item.height / 2
|
let y2 = item.top + item.height / 2
|
||||||
let path = ''
|
let path = ''
|
||||||
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
|
y1 = nodeUseLineStyle && !node.isRoot ? y1 + height / 2 : y1
|
||||||
@ -321,7 +334,8 @@ class MindMap extends Base {
|
|||||||
? height / 2
|
? height / 2
|
||||||
: 0
|
: 0
|
||||||
// 位置没有变化则返回
|
// 位置没有变化则返回
|
||||||
let _x = (node.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT ? 0 - expandBtnSize : width)
|
let _x =
|
||||||
|
node.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT ? 0 - expandBtnSize : width
|
||||||
let _y = height / 2 + nodeUseLineStyleOffset
|
let _y = height / 2 + nodeUseLineStyleOffset
|
||||||
if (_x === translateX && _y === translateY) {
|
if (_x === translateX && _y === translateY) {
|
||||||
return
|
return
|
||||||
@ -359,6 +373,15 @@ class MindMap extends Base {
|
|||||||
(isLeft ? gNode.width : 0)
|
(isLeft ? gNode.width : 0)
|
||||||
gNode.top = top + (bottom - top - gNode.height) / 2
|
gNode.top = top + (bottom - top - gNode.height) / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 渲染展开收起按钮的隐藏占位元素
|
||||||
|
renderExpandBtnRect(rect, expandBtnSize, width, height, node) {
|
||||||
|
if (node.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT) {
|
||||||
|
rect.size(expandBtnSize, height).x(-expandBtnSize).y(0)
|
||||||
|
} else {
|
||||||
|
rect.size(expandBtnSize, height).x(width).y(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MindMap
|
export default MindMap
|
||||||
|
|||||||
@ -255,6 +255,11 @@ class OrganizationStructure extends Base {
|
|||||||
gNode.top = bottom + generalizationNodeMargin
|
gNode.top = bottom + generalizationNodeMargin
|
||||||
gNode.left = left + (right - left - gNode.width) / 2
|
gNode.left = left + (right - left - gNode.width) / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 渲染展开收起按钮的隐藏占位元素
|
||||||
|
renderExpandBtnRect(rect, expandBtnSize, width, height, node) {
|
||||||
|
rect.size(width, expandBtnSize).x(0).y(height)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default OrganizationStructure
|
export default OrganizationStructure
|
||||||
|
|||||||
@ -336,6 +336,28 @@ class Timeline extends Base {
|
|||||||
gNode.left = right + generalizationNodeMargin
|
gNode.left = right + generalizationNodeMargin
|
||||||
gNode.top = top + (bottom - top - gNode.height) / 2
|
gNode.top = top + (bottom - top - gNode.height) / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 渲染展开收起按钮的隐藏占位元素
|
||||||
|
renderExpandBtnRect(rect, expandBtnSize, width, height, node) {
|
||||||
|
if (this.layout === CONSTANTS.LAYOUT.TIMELINE) {
|
||||||
|
rect.size(width, expandBtnSize).x(0).y(height)
|
||||||
|
} else {
|
||||||
|
let dir = ''
|
||||||
|
if (node.dir === CONSTANTS.LAYOUT_GROW_DIR.TOP) {
|
||||||
|
dir =
|
||||||
|
node.layerIndex === 1
|
||||||
|
? CONSTANTS.LAYOUT_GROW_DIR.TOP
|
||||||
|
: CONSTANTS.LAYOUT_GROW_DIR.BOTTOM
|
||||||
|
} else {
|
||||||
|
dir = CONSTANTS.LAYOUT_GROW_DIR.BOTTOM
|
||||||
|
}
|
||||||
|
if (dir === CONSTANTS.LAYOUT_GROW_DIR.TOP) {
|
||||||
|
rect.size(width, expandBtnSize).x(0).y(-expandBtnSize)
|
||||||
|
} else {
|
||||||
|
rect.size(width, expandBtnSize).x(0).y(height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Timeline
|
export default Timeline
|
||||||
|
|||||||
@ -46,7 +46,10 @@ class VerticalTimeline extends Base {
|
|||||||
if (parent._node.dir) {
|
if (parent._node.dir) {
|
||||||
newNode.dir = parent._node.dir
|
newNode.dir = parent._node.dir
|
||||||
} else {
|
} else {
|
||||||
newNode.dir = index % 2 === 0 ? CONSTANTS.LAYOUT_GROW_DIR.RIGHT : CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
newNode.dir =
|
||||||
|
index % 2 === 0
|
||||||
|
? CONSTANTS.LAYOUT_GROW_DIR.RIGHT
|
||||||
|
: CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
||||||
}
|
}
|
||||||
// 定位二级节点的left
|
// 定位二级节点的left
|
||||||
if (parent._node.isRoot) {
|
if (parent._node.isRoot) {
|
||||||
@ -321,7 +324,10 @@ class VerticalTimeline extends Base {
|
|||||||
? left - expandBtnSize
|
? left - expandBtnSize
|
||||||
: left + width + expandBtnSize
|
: left + width + expandBtnSize
|
||||||
let y1 = top + height / 2
|
let y1 = top + height / 2
|
||||||
let x2 = item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT ? item.left + item.width : item.left
|
let x2 =
|
||||||
|
item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
||||||
|
? item.left + item.width
|
||||||
|
: item.left
|
||||||
let y2 = item.top + item.height / 2
|
let y2 = item.top + item.height / 2
|
||||||
let path = `M ${x1},${y1} L ${x2},${y2}`
|
let path = `M ${x1},${y1} L ${x2},${y2}`
|
||||||
lines[index].plot(path)
|
lines[index].plot(path)
|
||||||
@ -358,7 +364,10 @@ class VerticalTimeline extends Base {
|
|||||||
? left - expandBtnSize
|
? left - expandBtnSize
|
||||||
: left + width + expandBtnSize
|
: left + width + expandBtnSize
|
||||||
let y1 = top + height / 2
|
let y1 = top + height / 2
|
||||||
let x2 = item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT ? item.left + item.width : item.left
|
let x2 =
|
||||||
|
item.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT
|
||||||
|
? item.left + item.width
|
||||||
|
: item.left
|
||||||
let y2 = item.top + item.height / 2
|
let y2 = item.top + item.height / 2
|
||||||
let path = this.cubicBezierPath(x1, y1, x2, y2)
|
let path = this.cubicBezierPath(x1, y1, x2, y2)
|
||||||
lines[index].plot(path)
|
lines[index].plot(path)
|
||||||
@ -408,6 +417,15 @@ class VerticalTimeline extends Base {
|
|||||||
(isLeft ? gNode.width : 0)
|
(isLeft ? gNode.width : 0)
|
||||||
gNode.top = top + (bottom - top - gNode.height) / 2
|
gNode.top = top + (bottom - top - gNode.height) / 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 渲染展开收起按钮的隐藏占位元素
|
||||||
|
renderExpandBtnRect(rect, expandBtnSize, width, height, node) {
|
||||||
|
if (node.dir === CONSTANTS.LAYOUT_GROW_DIR.LEFT) {
|
||||||
|
rect.size(expandBtnSize, height).x(-expandBtnSize).y(0)
|
||||||
|
} else {
|
||||||
|
rect.size(expandBtnSize, height).x(width).y(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default VerticalTimeline
|
export default VerticalTimeline
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user