From 9b96d10fb2a4d7a804c64f2a833b60a33e558296 Mon Sep 17 00:00:00 2001 From: yaoyun8 <142570291+yaoyun8@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:13:02 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E6=8F=92=E4=BB=B6=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=9B=BA=E5=AE=9A=E5=90=8E=E7=94=BB=E5=B8=83=E6=9C=AA?= =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=20(#234)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复数据源mock数据不一致 * fix:插件面板固定后画布未自适应 * fix:插件面板固定后画布未自适应 * fix:修复eslint报错 --- .../src/components/container/CanvasResize.vue | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/packages/canvas/src/components/container/CanvasResize.vue b/packages/canvas/src/components/container/CanvasResize.vue index 9e1f87c..4f249e5 100644 --- a/packages/canvas/src/components/container/CanvasResize.vue +++ b/packages/canvas/src/components/container/CanvasResize.vue @@ -30,13 +30,6 @@ export default { const mouseDown = ref(false) const resizeDom = ref(null) - const onMouseMove = (event) => { - if (mouseDown.value) { - event.preventDefault() - calculateSize(event) - } - } - const calculateSize = ({ movementX }) => { const dimension = useLayout().getDimension() const { maxWidth, minWidth, width } = dimension @@ -48,13 +41,10 @@ export default { }) } - const onMouseDown = () => { - const iframe = canvasState.iframe - - if (iframe) { - iframe.style['pointer-events'] = 'none' - bindEvents() - mouseDown.value = true + const onMouseMove = (event) => { + if (mouseDown.value) { + event.preventDefault() + calculateSize(event) } } @@ -64,7 +54,9 @@ export default { if (iframe) { iframe.style['pointer-events'] = 'auto' mouseDown.value = false - unbindEvents() + + document.removeEventListener('mousemove', onMouseMove, { passive: false }) + document.removeEventListener('mouseup', onMouseUp) } } @@ -73,9 +65,14 @@ export default { document.addEventListener('mouseup', onMouseUp) } - const unbindEvents = () => { - document.removeEventListener('mousemove', onMouseMove, { passive: false }) - document.removeEventListener('mouseup', onMouseUp) + const onMouseDown = () => { + const iframe = canvasState.iframe + + if (iframe) { + iframe.style['pointer-events'] = 'none' + bindEvents() + mouseDown.value = true + } } const setScale = () => { @@ -95,7 +92,13 @@ export default { watch( () => useLayout().getPluginState().render, - (value) => !value && setScale(), + (value) => { + const currentFixed = useLayout().getPluginState().fixedPanels.includes(value) + + if (!value || currentFixed) { + setScale() + } + }, { flush: 'post' } )