refactor(仪表板): 优化仪表板矩阵模式下的拖拽可能出现的松开手柄后大小再次变化,位置未置顶问题

This commit is contained in:
wangjiahao 2023-01-30 12:19:05 +08:00
parent 930c57ad2d
commit f590a72526
2 changed files with 19 additions and 14 deletions

View File

@ -126,7 +126,7 @@
:canvas-id="canvasId"
/>
<!-- 右击菜单 -->
<ContextMenu />
<ContextMenu/>
<!-- 对齐标线 -->
<span
@ -1055,7 +1055,6 @@ export default {
lineRef.init(newVal)
}
}
console.log(newVal)
})
},
deep: true

View File

@ -830,6 +830,22 @@ export default {
this.beforeDestroyFunction()
},
methods: {
sizeAdaptor() {
this.top = this.y
this.left = this.x
const [parentWidth, parentHeight] = this.getParentSize()
this.parentWidth = parentWidth
this.parentHeight = parentHeight
const [width, height] = getComputedSize(this.$el)
this.aspectFactor = (this.w !== 'auto' ? this.w : width) / (this.h !== 'auto' ? this.h : height)
if (this.outsideAspectRatio) {
this.aspectFactor = this.outsideAspectRatio
}
this.width = this.w !== 'auto' ? this.w : width
this.height = this.h !== 'auto' ? this.h : height
this.right = this.parentWidth - this.width - this.left
this.bottom = this.parentHeight - this.height - this.top
},
setChartData(chart) {
this.chart = chart
},
@ -1482,6 +1498,7 @@ export default {
this.hasMove && this.$store.commit('recordSnapshot', 'handleUp')
// snapshot false
this.hasMove = false
this.sizeAdaptor()
}, 200)
} else {
this.hasMove && this.$store.commit('recordSnapshot', 'handleUp')
@ -1890,18 +1907,7 @@ export default {
if (!this.enableNativeDrag) {
this.$el.ondragstart = () => false
}
const [parentWidth, parentHeight] = this.getParentSize()
this.parentWidth = parentWidth
this.parentHeight = parentHeight
const [width, height] = getComputedSize(this.$el)
this.aspectFactor = (this.w !== 'auto' ? this.w : width) / (this.h !== 'auto' ? this.h : height)
if (this.outsideAspectRatio) {
this.aspectFactor = this.outsideAspectRatio
}
this.width = this.w !== 'auto' ? this.w : width
this.height = this.h !== 'auto' ? this.h : height
this.right = this.parentWidth - this.width - this.left
this.bottom = this.parentHeight - this.height - this.top
this.sizeAdaptor()
// data-*
this.settingAttribute()