fix:插件面板固定后画布未自适应 (#234)

* fix: 修复数据源mock数据不一致

* fix:插件面板固定后画布未自适应

* fix:插件面板固定后画布未自适应

* fix:修复eslint报错
This commit is contained in:
yaoyun8 2024-01-10 16:13:02 +08:00 committed by GitHub
parent 2b5fe014f9
commit 9b96d10fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 19 deletions

View File

@ -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' }
)