修复隐藏模式下展开收起按钮的缺陷
This commit is contained in:
parent
e1b4146171
commit
38ad33b604
@ -68,6 +68,7 @@ class Node {
|
|||||||
this.noteEl = null
|
this.noteEl = null
|
||||||
this._expandBtn = null
|
this._expandBtn = null
|
||||||
this._lastExpandBtnType = null
|
this._lastExpandBtnType = null
|
||||||
|
this._showExpandBtn = false
|
||||||
this._openExpandNode = null
|
this._openExpandNode = null
|
||||||
this._closeExpandNode = null
|
this._closeExpandNode = null
|
||||||
this._fillExpandNode = null
|
this._fillExpandNode = null
|
||||||
@ -75,6 +76,7 @@ class Node {
|
|||||||
this._generalizationLine = null
|
this._generalizationLine = null
|
||||||
this._generalizationNode = null
|
this._generalizationNode = null
|
||||||
this._unVisibleRectRegionNode = null
|
this._unVisibleRectRegionNode = null
|
||||||
|
this._isMouseenter = false
|
||||||
// 尺寸信息
|
// 尺寸信息
|
||||||
this._rectInfo = {
|
this._rectInfo = {
|
||||||
imgContentWidth: 0,
|
imgContentWidth: 0,
|
||||||
@ -385,11 +387,13 @@ class Node {
|
|||||||
this.mindMap.emit('node_mouseup', this, e)
|
this.mindMap.emit('node_mouseup', this, e)
|
||||||
})
|
})
|
||||||
this.group.on('mouseenter', e => {
|
this.group.on('mouseenter', e => {
|
||||||
|
this._isMouseenter = true
|
||||||
// 显示展开收起按钮
|
// 显示展开收起按钮
|
||||||
this.showExpandBtn()
|
this.showExpandBtn()
|
||||||
this.mindMap.emit('node_mouseenter', this, e)
|
this.mindMap.emit('node_mouseenter', this, e)
|
||||||
})
|
})
|
||||||
this.group.on('mouseleave', e => {
|
this.group.on('mouseleave', e => {
|
||||||
|
this._isMouseenter = false
|
||||||
this.hideExpandBtn()
|
this.hideExpandBtn()
|
||||||
this.mindMap.emit('node_mouseleave', this, e)
|
this.mindMap.emit('node_mouseleave', this, e)
|
||||||
})
|
})
|
||||||
@ -449,8 +453,11 @@ class Node {
|
|||||||
this.renderExpandBtn()
|
this.renderExpandBtn()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 如果是收起状态,那么显示展开收起按钮
|
let { isActive, expand } = this.nodeData.data
|
||||||
if (!this.nodeData.data.expand) {
|
// 展开状态且非激活状态,且当前鼠标不在它上面,才隐藏
|
||||||
|
if (expand && !isActive && !this._isMouseenter) {
|
||||||
|
this.hideExpandBtn()
|
||||||
|
} else {
|
||||||
this.showExpandBtn()
|
this.showExpandBtn()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -757,14 +757,14 @@ class Render {
|
|||||||
item.render()
|
item.render()
|
||||||
})
|
})
|
||||||
node.renderLine()
|
node.renderLine()
|
||||||
node.updateExpandBtnNode()
|
// node.updateExpandBtnNode()
|
||||||
} else {
|
} else {
|
||||||
// 收缩
|
// 收缩
|
||||||
node.children.forEach(item => {
|
node.children.forEach(item => {
|
||||||
item.remove()
|
item.remove()
|
||||||
})
|
})
|
||||||
node.removeLine()
|
node.removeLine()
|
||||||
node.updateExpandBtnNode()
|
// node.updateExpandBtnNode()
|
||||||
}
|
}
|
||||||
this.mindMap.render()
|
this.mindMap.render()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,14 +98,16 @@ function renderExpandBtn() {
|
|||||||
})
|
})
|
||||||
this.group.add(this._expandBtn)
|
this.group.add(this._expandBtn)
|
||||||
}
|
}
|
||||||
|
this._showExpandBtn = true
|
||||||
this.updateExpandBtnNode()
|
this.updateExpandBtnNode()
|
||||||
this.updateExpandBtnPos()
|
this.updateExpandBtnPos()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移除展开收缩按钮
|
// 移除展开收缩按钮
|
||||||
function removeExpandBtn() {
|
function removeExpandBtn() {
|
||||||
if (this._expandBtn) {
|
if (this._expandBtn && this._showExpandBtn) {
|
||||||
this._expandBtn.remove()
|
this._expandBtn.remove()
|
||||||
|
this._showExpandBtn = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +121,7 @@ function showExpandBtn() {
|
|||||||
|
|
||||||
// 隐藏展开收起按钮
|
// 隐藏展开收起按钮
|
||||||
function hideExpandBtn() {
|
function hideExpandBtn() {
|
||||||
if (this.mindMap.opt.alwaysShowExpandBtn) return
|
if (this.mindMap.opt.alwaysShowExpandBtn || this._isMouseenter) return
|
||||||
// 非激活状态且展开状态鼠标移出才隐藏按钮
|
// 非激活状态且展开状态鼠标移出才隐藏按钮
|
||||||
let { isActive, expand } = this.nodeData.data
|
let { isActive, expand } = this.nodeData.data
|
||||||
if (!isActive && expand) {
|
if (!isActive && expand) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user