Merge pull request #7997 from dataease/pr@dev-v2@feat_component-radio

feat(数据大屏): 组件的宽高增加宽高比例锁定功能,可以等比放大缩小
This commit is contained in:
王嘉豪
2024-02-05 13:49:33 +08:00
committed by GitHub
4 changed files with 37 additions and 0 deletions

View File

@@ -608,6 +608,7 @@ const handleMouseDownOnPoint = (point, e) => {
let isFirst = true
const needLockProportion = isNeedLockProportion()
const originRadio = curComponent.value.style.width / curComponent.value.style.height
const move = moveEvent => {
// 第一次点击时也会触发 move所以会有“刚点击组件但未移动组件的大小却改变了”的情况发生
// 因此第一次点击时不触发 move 事件
@@ -628,6 +629,25 @@ const handleMouseDownOnPoint = (point, e) => {
})
//Temp dataV坐标偏移
offsetDataVAdaptor(style, point)
// 保持宽搞比例调整
if (curComponent.value.maintainRadio) {
// 高度偏移量
const heightOffset = style.height - defaultStyle.value.height
// 宽度偏移量
const widthOffset = style.width - defaultStyle.value.width
// 保持宽高比例是相对宽度偏移量
const adaptorWidthOffset = heightOffset * originRadio
// 保持宽高比例是相对高度偏移量
const adaptorHeightOffset = widthOffset / originRadio
if (Math.abs(widthOffset) > Math.abs(adaptorWidthOffset)) {
// 调整高度
style.height = defaultStyle.value.height + adaptorHeightOffset
} else {
// 调整宽度
style.width = defaultStyle.value.width + adaptorWidthOffset
}
}
dvMainStore.setShapeStyle(style)
// 矩阵逻辑 如果当前是仪表板(矩阵模式)则要进行矩阵重排
dashboardActive.value && emit('onResizing', moveEvent)