diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index 5c20049b..69dce84f 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -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') } diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index a8f68bfc..5b3d3e15 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -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) { diff --git a/simple-mind-map/src/plugins/Demonstrate.js b/simple-mind-map/src/plugins/Demonstrate.js index b43382f6..7d557d77 100644 --- a/simple-mind-map/src/plugins/Demonstrate.js +++ b/simple-mind-map/src/plugins/Demonstrate.js @@ -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 } // 暂停性能模式 diff --git a/simple-mind-map/src/utils/index.js b/simple-mind-map/src/utils/index.js index aca748e4..67b913dd 100644 --- a/simple-mind-map/src/utils/index.js +++ b/simple-mind-map/src/utils/index.js @@ -1505,6 +1505,7 @@ export const fullScreen = element => { // 退出全屏 export const exitFullScreen = () => { + if (!document.fullscreenElement) return if (document.exitFullscreen) { document.exitFullscreen() } else if (document.webkitExitFullscreen) {