优化性能:1.节点位置没有变化不触发位置设置;2.展开收起状态没有变化不触发按钮更新
This commit is contained in:
parent
942706fb63
commit
65151f4b0a
@ -67,6 +67,7 @@ class Node {
|
|||||||
this._noteData = null
|
this._noteData = null
|
||||||
this.noteEl = null
|
this.noteEl = null
|
||||||
this._expandBtn = null
|
this._expandBtn = null
|
||||||
|
this._lastExpandBtnType = null
|
||||||
this._openExpandNode = null
|
this._openExpandNode = null
|
||||||
this._closeExpandNode = null
|
this._closeExpandNode = null
|
||||||
this._fillExpandNode = null
|
this._fillExpandNode = null
|
||||||
@ -436,6 +437,8 @@ class Node {
|
|||||||
this.renderGeneralization()
|
this.renderGeneralization()
|
||||||
// 更新节点位置
|
// 更新节点位置
|
||||||
let t = this.group.transform()
|
let t = this.group.transform()
|
||||||
|
// 如果节点位置没有变化,则返回
|
||||||
|
if (this.left === t.translateX && this.top === t.translateY) return
|
||||||
if (!isLayout && enableNodeTransitionMove) {
|
if (!isLayout && enableNodeTransitionMove) {
|
||||||
this.group
|
this.group
|
||||||
.animate(nodeTransitionMoveDuration)
|
.animate(nodeTransitionMoveDuration)
|
||||||
|
|||||||
@ -245,9 +245,15 @@ class LogicalStructure extends Base {
|
|||||||
let nodeUseLineStyleOffset = this.mindMap.themeConfig.nodeUseLineStyle
|
let nodeUseLineStyleOffset = this.mindMap.themeConfig.nodeUseLineStyle
|
||||||
? height / 2
|
? height / 2
|
||||||
: 0
|
: 0
|
||||||
|
// 位置没有变化则返回
|
||||||
|
let _x = width
|
||||||
|
let _y = height / 2 + nodeUseLineStyleOffset
|
||||||
|
if (_x === translateX && _y === translateY) {
|
||||||
|
return
|
||||||
|
}
|
||||||
btn.translate(
|
btn.translate(
|
||||||
width - translateX,
|
_x - translateX,
|
||||||
height / 2 - translateY + nodeUseLineStyleOffset
|
_y - translateY
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -310,8 +310,14 @@ class MindMap extends Base {
|
|||||||
let nodeUseLineStyleOffset = this.mindMap.themeConfig.nodeUseLineStyle
|
let nodeUseLineStyleOffset = this.mindMap.themeConfig.nodeUseLineStyle
|
||||||
? height / 2
|
? height / 2
|
||||||
: 0
|
: 0
|
||||||
let x = (node.dir === 'left' ? 0 - expandBtnSize : width) - translateX
|
// 位置没有变化则返回
|
||||||
let y = height / 2 - translateY + nodeUseLineStyleOffset
|
let _x = (node.dir === 'left' ? 0 - expandBtnSize : width)
|
||||||
|
let _y = height / 2 + nodeUseLineStyleOffset
|
||||||
|
if (_x === translateX && _y === translateY) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let x = _x - translateX
|
||||||
|
let y = _y - translateY
|
||||||
btn.translate(x, y)
|
btn.translate(x, y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,8 @@ function createExpandNodeContent() {
|
|||||||
|
|
||||||
// 创建或更新展开收缩按钮内容
|
// 创建或更新展开收缩按钮内容
|
||||||
function updateExpandBtnNode() {
|
function updateExpandBtnNode() {
|
||||||
|
// 如果本次和上次的展开状态一样则返回
|
||||||
|
if (this.nodeData.data.expand === this._lastExpandBtnType) return
|
||||||
if (this._expandBtn) {
|
if (this._expandBtn) {
|
||||||
this._expandBtn.clear()
|
this._expandBtn.clear()
|
||||||
}
|
}
|
||||||
@ -39,8 +41,10 @@ function updateExpandBtnNode() {
|
|||||||
let node
|
let node
|
||||||
if (this.nodeData.data.expand === false) {
|
if (this.nodeData.data.expand === false) {
|
||||||
node = this._openExpandNode
|
node = this._openExpandNode
|
||||||
|
this._lastExpandBtnType = false
|
||||||
} else {
|
} else {
|
||||||
node = this._closeExpandNode
|
node = this._closeExpandNode
|
||||||
|
this._lastExpandBtnType = true
|
||||||
}
|
}
|
||||||
if (this._expandBtn) this._expandBtn.add(this._fillExpandNode).add(node)
|
if (this._expandBtn) this._expandBtn.add(this._fillExpandNode).add(node)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user