From 99256fa01cf42268f17e9c5189b00f2e3a28a84f Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 28 Sep 2026 19:45:15 +0200 Subject: [PATCH] Make drag & drop of floating tiles less janky This fixes an issue where upon dragging a floating tile to a different corner of the interface, it would briefly move toward its original position before jerking back in the intended direction. --- src/grid/Grid.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/grid/Grid.tsx b/src/grid/Grid.tsx index 69bfc0760..1e70475b2 100644 --- a/src/grid/Grid.tsx +++ b/src/grid/Grid.tsx @@ -198,6 +198,10 @@ interface Drag { * The Y coordinate of the dragged tile, as a scalar of the grid height. */ yRatio: number; + /** + * Whether this event ends the drag gesture. + */ + endOfGesture: boolean } export type DragCallback = (drag: Drag) => void; @@ -464,13 +468,13 @@ export function Grid< ) .catch(logger.error); - if (endOfGesture) - callback({ - x: tileX, - y: tileY, - xRatio: tileX / (gridBounds.width - tile.width), - yRatio: tileY / (gridBounds.height - tile.height), - }); + callback({ + x: tileX, + y: tileY, + xRatio: tileX / (gridBounds.width - tile.width), + yRatio: tileY / (gridBounds.height - tile.height), + endOfGesture, + }); }; // Callback for useDrag. We could call useDrag here, but the default