Fix:修复进入演示模式出错的问题

This commit is contained in:
wanglin2
2024-08-21 22:01:19 +08:00
parent 01b805a045
commit da49a0f58c
4 changed files with 22 additions and 1 deletions

View File

@@ -214,7 +214,14 @@ class MindMap {
this.svg.size(this.width, this.height)
if (oldWidth !== this.width || oldHeight !== this.height) {
// 如果画布宽高改变了需要触发一次渲染
this.render()
if (this.demonstrate) {
// 如果存在演示插件,并且正在演示中,那么不需要触发重新渲染,否则会冲突
if (!this.demonstrate.isInDemonstrate) {
this.render()
}
} else {
this.render()
}
}
this.emit('resize')
}

View File

@@ -2011,6 +2011,7 @@ class Render {
// 根据uid找到对应的节点实例
findNodeByUid(uid) {
if (!this.root) return
let res = null
walk(this.root, null, node => {
if (node.getData('uid') === uid) {

View File

@@ -22,6 +22,8 @@ const defaultConfig = {
class Demonstrate {
constructor(opt) {
this.mindMap = opt.mindMap
// 是否正在演示中
this.isInDemonstrate = false
// 演示的步骤列表
this.stepList = []
// 当前所在步骤
@@ -57,6 +59,7 @@ class Demonstrate {
}
_enter() {
this.isInDemonstrate = true
// 如果开启了性能模式,那么需要暂停
this.pausePerformanceMode()
// 添加演示用的临时的样式
@@ -74,8 +77,16 @@ class Demonstrate {
// 计算步骤数据
this.getStepList()
// 收起所有节点
let wait = false
if (this.mindMap.renderer.isRendering) {
wait = true
}
this.mindMap.execCommand('UNEXPAND_ALL', false)
const onRenderEnd = () => {
if (wait) {
wait = false
return
}
this.mindMap.off('node_tree_render_end', onRenderEnd)
// 聚焦到第一步
this.jump(this.currentStepIndex)
@@ -102,6 +113,7 @@ class Demonstrate {
this.mindMap.keyCommand.recovery()
this.restorePerformanceMode()
this.mindMap.emit('exit_demonstrate')
this.isInDemonstrate = false
}
// 暂停性能模式

View File

@@ -1505,6 +1505,7 @@ export const fullScreen = element => {
// 退出全屏
export const exitFullScreen = () => {
if (!document.fullscreenElement) return
if (document.exitFullscreen) {
document.exitFullscreen()
} else if (document.webkitExitFullscreen) {