From c1e233406d8ae2cbb064cd1b3a142aa8317162c7 Mon Sep 17 00:00:00 2001 From: Skaiir Date: Fri, 13 Sep 2024 13:06:26 +0200 Subject: [PATCH] fix: align drag preview/sticker properly Closes #596 --- .../src/features/dragging/Dragging.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/form-js-editor/src/features/dragging/Dragging.js b/packages/form-js-editor/src/features/dragging/Dragging.js index e0bf3d191..dca2f09e9 100644 --- a/packages/form-js-editor/src/features/dragging/Dragging.js +++ b/packages/form-js-editor/src/features/dragging/Dragging.js @@ -280,6 +280,35 @@ export class Dragging { return !target.classList.contains(DRAG_NO_DROP_CLS); }, + + transformOffset: (offset, event, element) => { + if (element.classList.contains(DRAG_ROW_MOVE_CLS)) { + const rowOffset = { + x: -5, + y: -60, + }; + + return { + left: event.clientX + rowOffset.x, + top: event.clientY + rowOffset.y, + }; + } + + if (element.classList.contains(DRAG_MOVE_CLS)) { + const iconOffset = { + x: -5, + y: -15, + }; + + return { + left: event.clientX + iconOffset.x, + top: event.clientY + iconOffset.y, + }; + } + + return offset; + }, + slideFactorX: 10, slideFactorY: 5, };