From 707872cd8e6c9ca6125e97210cf7a1fc277b5d12 Mon Sep 17 00:00:00 2001 From: Johnson Cherian Date: Tue, 24 Oct 2023 14:37:11 +0530 Subject: [PATCH] fix: fixed issues with snaping to grid --- frontend/src/Editor/DragContainer.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/Editor/DragContainer.jsx b/frontend/src/Editor/DragContainer.jsx index 59b5704644..502b3cb73d 100644 --- a/frontend/src/Editor/DragContainer.jsx +++ b/frontend/src/Editor/DragContainer.jsx @@ -273,12 +273,16 @@ export default function DragContainer({ if (parentElem) { left = left - parentElem.left * gridWidth; top = top - parentElem.top; + } else { + e.target.style.transform = `translate(${Math.round(left / gridWidth) * gridWidth}px, ${ + Math.round(top / 10) * 10 + }px)`; } onDrag([ { id: e.target.id, x: left, - y: top, + y: Math.round(top / 10) * 10, parent: draggedOverElemId, }, ]); @@ -337,6 +341,8 @@ export default function DragContainer({ snapThreshold={5} elementGuidelines={list.map((l) => ({ element: `.ele-${l.id}` }))} isDisplaySnapDigit={false} + snapGridWidth={gridWidth * 2} + // snapGridHeight={10} // verticalGuidelines={[50, 150, 250, 450, 550]} // horizontalGuidelines={[0, 100, 200, 400, 500]} />