From c8ad1a25b1e95ad865edbb9bbbb89d86ac207d8c Mon Sep 17 00:00:00 2001
From: wangjiahao <1522128093@qq.com>
Date: Wed, 4 Jan 2023 17:03:08 +0800
Subject: [PATCH] =?UTF-8?q?refactor(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9F=A9=E9=98=B5=E7=A7=BB=E5=8A=A8=E7=AE=97?=
=?UTF-8?q?=E6=B3=95=E5=87=8F=E5=B0=91=E7=BB=84=E4=BB=B6=E6=8B=96=E6=8B=BD?=
=?UTF-8?q?=E6=97=B6=E5=AF=BC=E8=87=B4=E7=9A=84=E5=8D=A1=E9=A1=BF=E7=8E=B0?=
=?UTF-8?q?=E8=B1=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../canvas/components/editor/DeEditor.vue | 78 ++++++++++---------
frontend/src/components/deDrag/index.vue | 2 +-
2 files changed, 43 insertions(+), 37 deletions(-)
diff --git a/frontend/src/components/canvas/components/editor/DeEditor.vue b/frontend/src/components/canvas/components/editor/DeEditor.vue
index 6b5c72af68..31234920ae 100644
--- a/frontend/src/components/canvas/components/editor/DeEditor.vue
+++ b/frontend/src/components/canvas/components/editor/DeEditor.vue
@@ -121,7 +121,7 @@
:canvas-id="canvasId"
/>
-
+
itemMaxY) {
itemMaxY = item.y + item.sizey
}
@@ -906,6 +906,12 @@ export default {
}
},
computed: {
+ matrixScaleWidth() {
+ return this.scalePointWidth / this.matrixStyle.width
+ },
+ matrixScaleHeight() {
+ return this.scalePointHeight / this.matrixStyle.height
+ },
moveTabCollisionActive() {
return this.tabCollisionActiveId
},
@@ -1609,37 +1615,35 @@ export default {
const startY = infoBox.startY
const moveXSize = e.pageX - startX // X方向移动的距离
const moveYSize = e.pageY - startY // Y方向移动的距离
-
- const addSizex = (moveXSize) % vm.cellWidth > (vm.cellWidth / 4 * 1) ? parseInt(((moveXSize) / vm.cellWidth + 1)) : parseInt(((moveXSize) / vm.cellWidth))
- const addSizey = (moveYSize) % vm.cellHeight > (vm.cellHeight / 4 * 1) ? parseInt(((moveYSize) / vm.cellHeight + 1)) : parseInt(((moveYSize) / vm.cellHeight))
- let nowX = Math.round((item.style.width * this.scalePointWidth) / this.matrixStyle.width)
- let nowY = Math.round((item.style.height * this.scalePointHeight) / this.matrixStyle.height)
+ let nowX = Math.round(item.style.width * this.matrixScaleWidth)
+ let nowY = Math.round(item.style.height * this.matrixScaleHeight)
nowX = nowX > 0 ? nowX : 1
nowY = nowY > 0 ? nowY : 1
const oldX = infoBox.oldX
const oldY = infoBox.oldY
- let newX = Math.round((item.style.left * this.scalePointWidth) / this.matrixStyle.width) + 1
- let newY = Math.round((item.style.top * this.scalePointHeight) / this.matrixStyle.height) + 1
+ let newX = Math.round(item.style.left * this.matrixScaleWidth) + 1
+ let newY = Math.round(item.style.top * this.matrixScaleHeight) + 1
newX = newX > 0 ? newX : 1
newY = newY > 0 ? newY : 1
- debounce((function(newX, oldX, newY, oldY, addSizex, addSizey) {
- return function() {
- if (newX !== oldX || oldY !== newY) {
- movePlayer.call(vm, resizeItem, {
- x: newX,
- y: newY
+ if (item.sizex !== nowX || item.sizey !== nowY) {
+ debounce((function(newX, oldX, newY, oldY) {
+ return function() {
+ if (newX !== oldX || oldY !== newY) {
+ movePlayer.call(vm, resizeItem, {
+ x: newX,
+ y: newY
+ })
+ infoBox.oldX = newX
+ infoBox.oldY = newY
+ }
+ resizePlayer.call(vm, resizeItem, {
+ sizex: nowX,
+ sizey: nowY
})
-
- infoBox.oldX = newX
- infoBox.oldY = newY
}
- resizePlayer.call(vm, resizeItem, {
- sizex: nowX,
- sizey: nowY
- })
- }
- })(newX, oldX, newY, oldY, addSizex, addSizey), 10)
+ })(newX, oldX, newY, oldY), 10)
+ }
},
onDragging(e, item) {
const infoBox = this.infoBox
@@ -1659,19 +1663,21 @@ export default {
if (this.moveTabCollisionActive) {
return
}
- debounce((function(newX, oldX, newY, oldY) {
- return function() {
- if (newX !== oldX || oldY !== newY) {
- movePlayer.call(vm, moveItem, {
- x: newX,
- y: newY
- })
+ if (newX !== oldX || oldY !== newY) {
+ debounce((function(newX, oldX, newY, oldY) {
+ return function() {
+ if (newX !== oldX || oldY !== newY) {
+ movePlayer.call(vm, moveItem, {
+ x: newX,
+ y: newY
+ })
- infoBox.oldX = newX
- infoBox.oldY = newY
+ infoBox.oldX = newX
+ infoBox.oldY = newY
+ }
}
- }
- })(newX, oldX, newY, oldY), 10)
+ })(newX, oldX, newY, oldY), 10)
+ }
},
endMove(e) {
diff --git a/frontend/src/components/deDrag/index.vue b/frontend/src/components/deDrag/index.vue
index 251764faa9..b9739ab4f8 100644
--- a/frontend/src/components/deDrag/index.vue
+++ b/frontend/src/components/deDrag/index.vue
@@ -1480,7 +1480,7 @@ export default {
this.hasMove && this.$store.commit('recordSnapshot', 'handleUp')
// 记录snapshot后 移动已记录设置为false
this.hasMove = false
- }, 100)
+ }, 200)
} else {
this.hasMove && this.$store.commit('recordSnapshot', 'handleUp')
// 记录snapshot后 移动已记录设置为false