diff --git a/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue b/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue index 104ca43bfe..73f85fdb13 100644 --- a/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue +++ b/core/core-frontend/src/components/data-visualization/canvas/CanvasCore.vue @@ -54,10 +54,10 @@ const dvMainStore = dvMainStoreWithOut() const composeStore = composeStoreWithOut() const contextmenuStore = contextmenuStoreWithOut() -const { curComponent, dvInfo, editMode, tabMoveOutComponentId, canvasState } = +const { curComponent, dvInfo, editMode, tabMoveOutComponentId, canvasState, mainScrollTop } = storeToRefs(dvMainStore) const { editorMap, areaData, isCtrlOrCmdDown } = storeToRefs(composeStore) -const emits = defineEmits(['scrollCanvasToTop']) +const emits = defineEmits(['scrollCanvasAdjust']) const props = defineProps({ themes: { type: String, @@ -1377,7 +1377,8 @@ const handleDragStartMoveIn = componentInfo => { adaptCurThemeCommonStyle(moveInItemInfo) } addItemBox(moveInItemInfo) - emits('scrollCanvasToTop') + // 直接定位到当前画布位置 + // emits('scrollCanvasAdjust', 1) if (!infoBox.value) { infoBox.value = {} } @@ -1400,7 +1401,7 @@ const handleDragOver = e => { return } infoBox.value.moveItem.style.left = e.pageX - infoBox.value.moveItem.style.top = e.pageY + infoBox.value.moveItem.style.top = e.pageY + mainScrollTop.value onDragging(e, infoBox.value.moveItem, 0) } diff --git a/core/core-frontend/src/views/canvas/DeCanvas.vue b/core/core-frontend/src/views/canvas/DeCanvas.vue index 303970ffe4..ac48c6030f 100644 --- a/core/core-frontend/src/views/canvas/DeCanvas.vue +++ b/core/core-frontend/src/views/canvas/DeCanvas.vue @@ -271,7 +271,7 @@ const getBaseMatrixSize = () => { } } -const scrollTo = y => { +const scrollTo = (y = 1) => { setTimeout(() => { canvasInner.value.scrollTo({ top: (y - 1) * baseHeight.value, @@ -334,7 +334,7 @@ defineExpose({ :base-width="baseWidth" :base-height="baseHeight" :font-family="fontFamily" - @scrollCanvasToTop="scrollTo(1)" + @scrollCanvasAdjust="scrollTo" >