From 82abe6c6ad5e81c8e7d05090dd43742844db1d3c Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 13 Oct 2021 17:38:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=E5=A2=9E=E5=8A=A0=E6=8B=96=E6=8B=BD?= =?UTF-8?q?=E9=98=B4=E5=BD=B1=E5=8A=A8=E7=94=BB=EF=BC=8C=E9=9D=A0=E5=8F=B3?= =?UTF-8?q?=E8=BE=B9=E7=95=8C=E7=9F=A9=E9=98=B5=E7=BB=84=E4=BB=B6=E6=94=B9?= =?UTF-8?q?=E5=8F=98=E5=A4=A7=E5=B0=8F=E5=8F=AF=E8=83=BD=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E4=B8=8D=E5=87=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/DeDrag/shadow.vue | 8 +++++++ .../canvas/components/Editor/index.vue | 21 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/DeDrag/shadow.vue b/frontend/src/components/DeDrag/shadow.vue index 927096197e..97bcfd614a 100644 --- a/frontend/src/components/DeDrag/shadow.vue +++ b/frontend/src/components/DeDrag/shadow.vue @@ -18,6 +18,7 @@ export default { let top = 0 let width = 0 let height = 0 + let transition = 0 // if (this.dragComponentInfo && !this.dragComponentInfo.auxiliaryMatrix) { if (this.dragComponentInfo) { // console.log('shadowDrag=') @@ -28,6 +29,7 @@ export default { width = this.dragComponentInfo.sizex * this.curCanvasScale.matrixStyleWidth height = this.dragComponentInfo.sizey * this.curCanvasScale.matrixStyleHeight + transition = 0.1 } else { left = this.dragComponentInfo.shadowStyle.x top = this.dragComponentInfo.shadowStyle.y @@ -45,6 +47,9 @@ export default { width = this.curComponent.style.width * this.curCanvasScale.scalePointWidth height = this.curComponent.style.height * this.curCanvasScale.scalePointHeight + if (this.curComponent.optStatus.dragging) { + transition = 0.1 + } // console.log('curComponent left:' + left + 'top:' + top + 'width:' + width + 'height:' + height) } @@ -59,6 +64,9 @@ export default { width: width + 'px', height: height + 'px' } + if (transition > 0) { + style.transition = transition + 's' + } // console.log('style=>' + JSON.stringify(style)) // 记录外部拖拽进入仪表板时阴影区域宽高 if (this.dragComponentInfo) { diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index 045fa9bf7c..3bec402bf6 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -1480,14 +1480,31 @@ export default { nowX = nowX > 0 ? nowX : 1 nowY = nowY > 0 ? nowY : 1 - debounce((function(addSizex, addSizey) { + 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 + newX = newX > 0 ? newX : 1 + newY = newY > 0 ? newY : 1 + debounce((function(newX, oldX, newY, oldY, addSizex, addSizey) { return function() { + // console.log('move1') + if (newX !== oldX || oldY !== newY) { + // console.log('move2') + movePlayer.call(vm, resizeItem, { + x: newX, + y: newY + }) + + infoBox.oldX = newX + infoBox.oldY = newY + } resizePlayer.call(vm, resizeItem, { sizex: nowX, sizey: nowY }) } - })(addSizex, addSizey), 10) + })(newX, oldX, newY, oldY, addSizex, addSizey), 10) }, onDragging(e, item) { const infoBox = this.infoBox