From 617d543250d1606932eb2514e47781d4ef203249 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Tue, 2 Jan 2024 17:46:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=A7=86=E5=9B=BE):=20=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=A1=86=E5=AF=BC=E8=87=B4=E9=87=8D=E7=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/canvas/DeCanvas.vue | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/core/frontend/src/components/canvas/DeCanvas.vue b/core/frontend/src/components/canvas/DeCanvas.vue index 4c206ddadf..901e9e5361 100644 --- a/core/frontend/src/components/canvas/DeCanvas.vue +++ b/core/frontend/src/components/canvas/DeCanvas.vue @@ -175,7 +175,9 @@ export default { outStyle: { width: null, height: null - } + }, + resizeObserver: null, + resizerTimer: null } }, computed: { @@ -239,18 +241,18 @@ export default { created() { }, mounted() { - const _this = this - // 监听div变动事件 - const erd = elementResizeDetectorMaker() - erd.listenTo(document.getElementById(this.canvasDomId), element => { - _this.$nextTick(() => { - _this.restore() - }) + this.resizeObserver = new ResizeObserver(() => { + this.resizerTimer && clearTimeout(this.resizerTimer) + this.resizerTimer = setTimeout(() => { + this.$nextTick(this.restore) + }, 500) }) + this.resizeObserver.observe(document.getElementById(this.canvasDomId)) }, beforeDestroy() { bus.$off('component-dialog-edit', this.editDialog) bus.$off('button-dialog-edit', this.editButtonDialog) + this.resizeObserver?.disconnect() }, methods: { getWrapperChildRefs() {