From dc5247c4dbc42be777f0396707154cf93ecbf96c Mon Sep 17 00:00:00 2001 From: christian Date: Sun, 3 Nov 2024 12:57:42 +0100 Subject: [PATCH] no more box offset --- app/routes/DragableBox.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/routes/DragableBox.tsx b/app/routes/DragableBox.tsx index aabf442..e2138e2 100644 --- a/app/routes/DragableBox.tsx +++ b/app/routes/DragableBox.tsx @@ -34,13 +34,12 @@ const DraggableBox = ({ const parent = dragRef.current.parentElement; const parentRect = parent.getBoundingClientRect(); - const boxRect = dragRef.current.getBoundingClientRect(); const relativeX = e.clientX - parentRect.left - dragOffset.x; const relativeY = e.clientY - parentRect.top - dragOffset.y; - const maxX = parentRect.width - boxRect.width; - const maxY = parentRect.height - boxRect.height; + const maxX = parentRect.width; + const maxY = parentRect.height; let newX = (Math.max(0, Math.min(relativeX, maxX))); let newY = (Math.max(0, Math.min(relativeY, maxY)));