feat: 增加默认配置fit,支持初始化的时候是否fit view
This commit is contained in:
parent
1452fd2a28
commit
e063724ab6
@ -36,7 +36,8 @@ class MindMap {
|
|||||||
// 画布宽高
|
// 画布宽高
|
||||||
this.width = this.elRect.width
|
this.width = this.elRect.width
|
||||||
this.height = this.elRect.height
|
this.height = this.elRect.height
|
||||||
if (this.width <= 0 || this.height <= 0) throw new Error('容器元素el的宽高不能为0')
|
if (this.width <= 0 || this.height <= 0)
|
||||||
|
throw new Error('容器元素el的宽高不能为0')
|
||||||
|
|
||||||
// 添加css
|
// 添加css
|
||||||
this.cssEl = null
|
this.cssEl = null
|
||||||
@ -87,7 +88,7 @@ class MindMap {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// 初始渲染
|
// 初始渲染
|
||||||
this.render()
|
this.render(this.opt.fit ? () => this.view.fit() : () => {})
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.command.addHistory()
|
this.command.addHistory()
|
||||||
}, 0)
|
}, 0)
|
||||||
|
|||||||
@ -186,5 +186,7 @@ export const defaultOpt = {
|
|||||||
// 删除节点后激活相邻节点
|
// 删除节点后激活相邻节点
|
||||||
deleteNodeActive: true,
|
deleteNodeActive: true,
|
||||||
// 拖拽节点时鼠标移动到画布边缘是否开启画布自动移动
|
// 拖拽节点时鼠标移动到画布边缘是否开启画布自动移动
|
||||||
autoMoveWhenMouseInEdgeOnDrag: true
|
autoMoveWhenMouseInEdgeOnDrag: true,
|
||||||
|
// 是否首次加载fit view
|
||||||
|
fit: false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,10 +12,7 @@
|
|||||||
<ShortcutKey></ShortcutKey>
|
<ShortcutKey></ShortcutKey>
|
||||||
<Contextmenu v-if="mindMap" :mindMap="mindMap"></Contextmenu>
|
<Contextmenu v-if="mindMap" :mindMap="mindMap"></Contextmenu>
|
||||||
<RichTextToolbar v-if="mindMap" :mindMap="mindMap"></RichTextToolbar>
|
<RichTextToolbar v-if="mindMap" :mindMap="mindMap"></RichTextToolbar>
|
||||||
<NodeNoteContentShow
|
<NodeNoteContentShow v-if="mindMap" :mindMap="mindMap"></NodeNoteContentShow>
|
||||||
v-if="mindMap"
|
|
||||||
:mindMap="mindMap"
|
|
||||||
></NodeNoteContentShow>
|
|
||||||
<NodeImgPreview v-if="mindMap" :mindMap="mindMap"></NodeImgPreview>
|
<NodeImgPreview v-if="mindMap" :mindMap="mindMap"></NodeImgPreview>
|
||||||
<SidebarTrigger v-if="!isZenMode"></SidebarTrigger>
|
<SidebarTrigger v-if="!isZenMode"></SidebarTrigger>
|
||||||
<Search v-if="mindMap" :mindMap="mindMap"></Search>
|
<Search v-if="mindMap" :mindMap="mindMap"></Search>
|
||||||
@ -279,6 +276,7 @@ export default {
|
|||||||
this.mindMap = new MindMap({
|
this.mindMap = new MindMap({
|
||||||
el: this.$refs.mindMapContainer,
|
el: this.$refs.mindMapContainer,
|
||||||
data: root,
|
data: root,
|
||||||
|
fit: true,
|
||||||
layout: layout,
|
layout: layout,
|
||||||
theme: theme.template,
|
theme: theme.template,
|
||||||
themeConfig: theme.config,
|
themeConfig: theme.config,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user