Skip to content

Commit

Permalink
add drop handling improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
JollyGrin committed Sep 11, 2024
1 parent d68791f commit 096270c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/utils/actions/grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 096270c

Please sign in to comment.