Feat:修复调整容器大小后回到根节点的操作异常的问题
This commit is contained in:
parent
4cf66adc18
commit
6d780c6c26
@ -173,8 +173,8 @@ export const defaultOpt = {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
// 开启鼠标双击复位思维导图位置及缩放
|
// 是否在鼠标双击时回到根节点,也就是让根节点居中显示
|
||||||
enableDblclickReset: false,
|
enableDblclickBackToRootNode: false,
|
||||||
// 导出图片时canvas的缩放倍数,该配置会和window.devicePixelRatio值取最大值
|
// 导出图片时canvas的缩放倍数,该配置会和window.devicePixelRatio值取最大值
|
||||||
minExportImgCanvasScale: 2,
|
minExportImgCanvasScale: 2,
|
||||||
// 节点鼠标hover和激活时显示的矩形边框的颜色
|
// 节点鼠标hover和激活时显示的矩形边框的颜色
|
||||||
|
|||||||
@ -122,6 +122,11 @@ class Render {
|
|||||||
this.mindMap.execCommand('CLEAR_ACTIVE_NODE')
|
this.mindMap.execCommand('CLEAR_ACTIVE_NODE')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 鼠标双击回到根节点
|
||||||
|
this.mindMap.svg.on('dblclick', () => {
|
||||||
|
if (!this.mindMap.opt.enableDblclickBackToRootNode) return
|
||||||
|
this.setRootNodeCenter()
|
||||||
|
})
|
||||||
// let timer = null
|
// let timer = null
|
||||||
// this.mindMap.on('view_data_change', () => {
|
// this.mindMap.on('view_data_change', () => {
|
||||||
// clearTimeout(timer)
|
// clearTimeout(timer)
|
||||||
@ -299,6 +304,10 @@ class Render {
|
|||||||
})
|
})
|
||||||
this.cut = this.cut.bind(this)
|
this.cut = this.cut.bind(this)
|
||||||
this.mindMap.keyCommand.addShortcut('Control+x', this.cut)
|
this.mindMap.keyCommand.addShortcut('Control+x', this.cut)
|
||||||
|
// 根节点居中显示
|
||||||
|
this.mindMap.keyCommand.addShortcut('Control+Enter', () => {
|
||||||
|
this.setRootNodeCenter()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 开启文字编辑,会禁用回车键和删除键相关快捷键防止冲突
|
// 开启文字编辑,会禁用回车键和删除键相关快捷键防止冲突
|
||||||
@ -557,12 +566,11 @@ class Render {
|
|||||||
const index = parent.nodeData.children.findIndex(item => {
|
const index = parent.nodeData.children.findIndex(item => {
|
||||||
return item.data.uid === node.uid
|
return item.data.uid === node.uid
|
||||||
})
|
})
|
||||||
const newNodeList = createUidForAppointNodes(simpleDeepClone(nodeList), true)
|
const newNodeList = createUidForAppointNodes(
|
||||||
parent.nodeData.children.splice(
|
simpleDeepClone(nodeList),
|
||||||
index + 1,
|
true
|
||||||
0,
|
|
||||||
...newNodeList
|
|
||||||
)
|
)
|
||||||
|
parent.nodeData.children.splice(index + 1, 0, ...newNodeList)
|
||||||
})
|
})
|
||||||
Object.keys(needDestroyNodeList).forEach(key => {
|
Object.keys(needDestroyNodeList).forEach(key => {
|
||||||
needDestroyNodeList[key].destroy()
|
needDestroyNodeList[key].destroy()
|
||||||
@ -1432,6 +1440,11 @@ class Render {
|
|||||||
this.mindMap.view.setScale(1)
|
this.mindMap.view.setScale(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 回到中心主题,即设置根节点到画布中心
|
||||||
|
setRootNodeCenter() {
|
||||||
|
this.moveNodeToCenter(this.root)
|
||||||
|
}
|
||||||
|
|
||||||
// 展开到指定uid的节点
|
// 展开到指定uid的节点
|
||||||
expandToNodeUid(uid, callback = () => {}) {
|
expandToNodeUid(uid, callback = () => {}) {
|
||||||
let parentsList = []
|
let parentsList = []
|
||||||
|
|||||||
@ -25,16 +25,9 @@ class View {
|
|||||||
this.mindMap.keyCommand.addShortcut('Control+-', () => {
|
this.mindMap.keyCommand.addShortcut('Control+-', () => {
|
||||||
this.narrow()
|
this.narrow()
|
||||||
})
|
})
|
||||||
this.mindMap.keyCommand.addShortcut('Control+Enter', () => {
|
|
||||||
this.reset()
|
|
||||||
})
|
|
||||||
this.mindMap.keyCommand.addShortcut('Control+i', () => {
|
this.mindMap.keyCommand.addShortcut('Control+i', () => {
|
||||||
this.fit()
|
this.fit()
|
||||||
})
|
})
|
||||||
this.mindMap.svg.on('dblclick', () => {
|
|
||||||
if (!this.mindMap.opt.enableDblclickReset) return
|
|
||||||
this.reset()
|
|
||||||
})
|
|
||||||
// 拖动视图
|
// 拖动视图
|
||||||
this.mindMap.event.on('mousedown', () => {
|
this.mindMap.event.on('mousedown', () => {
|
||||||
this.sx = this.x
|
this.sx = this.x
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user