Fix:修复快速操作时节点位置不正确的问题
This commit is contained in:
parent
af148fef27
commit
388594e29a
@ -82,7 +82,13 @@ const defaultOpt = {
|
|||||||
expandBtnIcon: {
|
expandBtnIcon: {
|
||||||
open: '',// svg字符串
|
open: '',// svg字符串
|
||||||
close: ''
|
close: ''
|
||||||
}
|
},
|
||||||
|
// 是否只有当鼠标在画布内才响应快捷键事件
|
||||||
|
enableShortcutOnlyWhenMouseInSvg: true,
|
||||||
|
// 是否开启节点动画过渡
|
||||||
|
enableNodeTransitionMove: true,
|
||||||
|
// 如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms
|
||||||
|
nodeTransitionMoveDuration: 300
|
||||||
}
|
}
|
||||||
|
|
||||||
// 思维导图
|
// 思维导图
|
||||||
|
|||||||
@ -52,7 +52,7 @@ export default class KeyCommand {
|
|||||||
this.isInSvg = false
|
this.isInSvg = false
|
||||||
})
|
})
|
||||||
window.addEventListener('keydown', e => {
|
window.addEventListener('keydown', e => {
|
||||||
if (this.isPause || !this.isInSvg) {
|
if (this.isPause || (this.mindMap.opt.enableShortcutOnlyWhenMouseInSvg && !this.isInSvg)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Object.keys(this.shortcutMap).forEach(key => {
|
Object.keys(this.shortcutMap).forEach(key => {
|
||||||
|
|||||||
@ -414,6 +414,7 @@ class Node {
|
|||||||
if (!this.group) {
|
if (!this.group) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
let { enableNodeTransitionMove, nodeTransitionMoveDuration } = this.mindMap.opt
|
||||||
// 需要移除展开收缩按钮
|
// 需要移除展开收缩按钮
|
||||||
if (this._expandBtn && this.nodeData.children.length <= 0) {
|
if (this._expandBtn && this.nodeData.children.length <= 0) {
|
||||||
this.removeExpandBtn()
|
this.removeExpandBtn()
|
||||||
@ -425,9 +426,9 @@ class Node {
|
|||||||
this.renderGeneralization()
|
this.renderGeneralization()
|
||||||
// 更新节点位置
|
// 更新节点位置
|
||||||
let t = this.group.transform()
|
let t = this.group.transform()
|
||||||
if (!isLayout) {
|
if (!isLayout && enableNodeTransitionMove) {
|
||||||
this.group
|
this.group
|
||||||
.animate(300)
|
.animate(nodeTransitionMoveDuration)
|
||||||
.translate(
|
.translate(
|
||||||
this.left - t.translateX,
|
this.left - t.translateX,
|
||||||
this.top - t.translateY
|
this.top - t.translateY
|
||||||
@ -457,10 +458,13 @@ class Node {
|
|||||||
|
|
||||||
// 递归渲染
|
// 递归渲染
|
||||||
render(callback = () => {}) {
|
render(callback = () => {}) {
|
||||||
|
let { enableNodeTransitionMove, nodeTransitionMoveDuration } = this.mindMap.opt
|
||||||
// 节点
|
// 节点
|
||||||
// 重新渲染连线
|
// 重新渲染连线
|
||||||
this.renderLine()
|
this.renderLine()
|
||||||
|
let isLayout = false
|
||||||
if (!this.group) {
|
if (!this.group) {
|
||||||
|
isLayout = true
|
||||||
// 创建组
|
// 创建组
|
||||||
this.group = new G()
|
this.group = new G()
|
||||||
this.group.css({
|
this.group.css({
|
||||||
@ -469,7 +473,7 @@ class Node {
|
|||||||
this.bindGroupEvent()
|
this.bindGroupEvent()
|
||||||
this.draw.add(this.group)
|
this.draw.add(this.group)
|
||||||
this.layout()
|
this.layout()
|
||||||
this.update(true)
|
this.update(isLayout)
|
||||||
} else {
|
} else {
|
||||||
this.draw.add(this.group)
|
this.draw.add(this.group)
|
||||||
if (this.needLayout) {
|
if (this.needLayout) {
|
||||||
@ -498,7 +502,13 @@ class Node {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
callback()
|
if (enableNodeTransitionMove && !isLayout) {
|
||||||
|
setTimeout(() => {
|
||||||
|
callback()
|
||||||
|
}, nodeTransitionMoveDuration)
|
||||||
|
} else {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 手动插入的节点立即获得焦点并且开启编辑模式
|
// 手动插入的节点立即获得焦点并且开启编辑模式
|
||||||
if (this.nodeData.inserting) {
|
if (this.nodeData.inserting) {
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class Base {
|
|||||||
newNode.getSize()
|
newNode.getSize()
|
||||||
newNode.needLayout = true
|
newNode.needLayout = true
|
||||||
}
|
}
|
||||||
} else if (this.nodePool[data.data.uid]) {
|
} else if (this.nodePool[data.data.uid] && !this.renderer.reRender) {
|
||||||
// 数据上没有保存节点引用,但是通过uid找到了缓存的节点,也可以复用
|
// 数据上没有保存节点引用,但是通过uid找到了缓存的节点,也可以复用
|
||||||
newNode = this.nodePool[data.data.uid]
|
newNode = this.nodePool[data.data.uid]
|
||||||
// 保存该节点上一次的数据
|
// 保存该节点上一次的数据
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user