Merge pull request #8212 from dataease/pr@dev-v2@fix_move-adaptor

fix(数据大屏): 修复保持宽高比时部分拖拽点拖拽时是同时出现位移问题
This commit is contained in:
王嘉豪 2024-02-28 14:41:32 +08:00 committed by GitHub
commit eeb81c981e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 2 deletions

View File

@ -87,7 +87,9 @@
<script setup lang="ts">
import eventBus from '@/utils/eventBus'
import calculateComponentPositionAndSize from '@/utils/calculateComponentPositionAndSize'
import calculateComponentPositionAndSize, {
calculateRadioComponentPositionAndSize
} from '@/utils/calculateComponentPositionAndSize'
import { mod360 } from '@/utils/translate'
import { deepCopy } from '@/utils/utils'
import { computed, nextTick, onMounted, ref, toRefs, reactive } from 'vue'
@ -670,8 +672,8 @@ const handleMouseDownOnPoint = (point, e) => {
//
style.width = defaultStyle.value.height * originRadio
}
calculateRadioComponentPositionAndSize(point, style, symmetricPoint)
}
dvMainStore.setShapeStyle(style)
//
dashboardActive.value && emit('onResizing', moveEvent)

View File

@ -373,3 +373,28 @@ export default function calculateComponentPositionAndSize(
) {
funcs[name](style, curPosition, proportion, needLockProportion, pointInfo)
}
export function calculateRadioComponentPositionAndSize(name, style, symmetricPoint) {
if (['b'].includes(name)) {
style.left = Math.round(symmetricPoint.x - style.width / 2)
style.top = symmetricPoint.y
} else if (['t'].includes(name)) {
style.left = Math.round(symmetricPoint.x - style.width / 2)
style.top = symmetricPoint.y - style.height
} else if (['l'].includes(name)) {
style.left = symmetricPoint.x - style.width
style.top = Math.round(symmetricPoint.y - style.height / 2)
} else if (['r'].includes(name)) {
style.left = symmetricPoint.x
style.top = Math.round(symmetricPoint.y - style.height / 2)
} else if (['lt'].includes(name)) {
style.left = symmetricPoint.x - style.width
style.top = symmetricPoint.y - style.height
} else if (['lb'].includes(name)) {
style.left = symmetricPoint.x - style.width
style.top = symmetricPoint.y
} else if (['rt'].includes(name)) {
style.left = symmetricPoint.x
style.top = symmetricPoint.y - style.height
}
}