From d21a80b1170c5e370b1554e20f99afa5338e1d87 Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Mon, 19 Jan 2026 17:39:00 -0300 Subject: [PATCH] fix: drag elements Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- src/components/DraggableElement.vue | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/components/DraggableElement.vue b/src/components/DraggableElement.vue index df9e7ab..b8341fb 100644 --- a/src/components/DraggableElement.vue +++ b/src/components/DraggableElement.vue @@ -153,10 +153,18 @@ export default { }, elementStyle() { const scale = this.pagesScale || 1 - const currentX = this.object.x + this.offsetX + this.resizeOffsetX - const currentY = this.object.y + this.offsetY + this.resizeOffsetY - const currentWidth = this.object.width + this.resizeOffsetW - const currentHeight = this.object.height + this.resizeOffsetH + const isDragging = this.mode === 'drag' + const isResizing = this.mode === 'resize' + const offsetX = isDragging ? this.offsetX : 0 + const offsetY = isDragging ? this.offsetY : 0 + const resizeOffsetX = isResizing ? this.resizeOffsetX : 0 + const resizeOffsetY = isResizing ? this.resizeOffsetY : 0 + const resizeOffsetW = isResizing ? this.resizeOffsetW : 0 + const resizeOffsetH = isResizing ? this.resizeOffsetH : 0 + const currentX = this.object.x + offsetX + resizeOffsetX + const currentY = this.object.y + offsetY + resizeOffsetY + const currentWidth = this.object.width + resizeOffsetW + const currentHeight = this.object.height + resizeOffsetH return { left: `${currentX * scale}px`, top: `${currentY * scale}px`, @@ -166,9 +174,16 @@ export default { }, toolbarStyle() { const scale = this.pagesScale || 1 - const x = this.object.x + this.offsetX + this.resizeOffsetX - const y = this.object.y + this.offsetY + this.resizeOffsetY - const width = this.object.width + this.resizeOffsetW + const isDragging = this.mode === 'drag' + const isResizing = this.mode === 'resize' + const offsetX = isDragging ? this.offsetX : 0 + const offsetY = isDragging ? this.offsetY : 0 + const resizeOffsetX = isResizing ? this.resizeOffsetX : 0 + const resizeOffsetY = isResizing ? this.resizeOffsetY : 0 + const resizeOffsetW = isResizing ? this.resizeOffsetW : 0 + const x = this.object.x + offsetX + resizeOffsetX + const y = this.object.y + offsetY + resizeOffsetY + const width = this.object.width + resizeOffsetW return { left: `${(x + width / 2) * scale}px`, top: `${(y - 60) * scale}px`,