From 096270c69ad7f0cc3d1e3c1aab9737eaec72e198 Mon Sep 17 00:00:00 2001 From: jollygrin Date: Wed, 11 Sep 2024 02:23:40 +0200 Subject: [PATCH] add drop handling improvements --- src/utils/actions/grid.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils/actions/grid.ts b/src/utils/actions/grid.ts index 466564c..92b1613 100644 --- a/src/utils/actions/grid.ts +++ b/src/utils/actions/grid.ts @@ -39,8 +39,15 @@ export function actMoveCardOutsideCell(state: GameState, event: DragEndEvent) { event.active?.data?.current?.index, 1, ); - // Place card in the destination area - updatedGrid[destinationIndex]?.push(movedCard); + + // Adjust order of where card is dropped for better UX + if (movedCard.type === "site") { + // place on bottom of stack + updatedGrid[destinationIndex]?.push(movedCard); + } else { + // place on top of stack + updatedGrid[destinationIndex]?.unshift(movedCard); + } return updatedGrid; }