From da49a0f58cc5068b40e543cd9cc9c41d2fa4ca68 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Wed, 21 Aug 2024 22:01:19 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=E4=BF=AE=E5=A4=8D=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E6=BC=94=E7=A4=BA=E6=A8=A1=E5=BC=8F=E5=87=BA=E9=94=99=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/index.js | 9 ++++++++- simple-mind-map/src/core/render/Render.js | 1 + simple-mind-map/src/plugins/Demonstrate.js | 12 ++++++++++++ simple-mind-map/src/utils/index.js | 1 + 4 files changed, 22 insertions(+), 1 deletion(-) 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) {