From 6157a4f571a2883d30627f1498d4fcdea66bdd3e Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Wed, 26 Nov 2025 18:09:36 +0100 Subject: [PATCH] docs: Add design document for spatial workspace architecture refactor and fix card center calculation in layout system. --- frontend/src/desktop/LayoutSystem.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/frontend/src/desktop/LayoutSystem.ts b/frontend/src/desktop/LayoutSystem.ts index bf17664..26c0796 100644 --- a/frontend/src/desktop/LayoutSystem.ts +++ b/frontend/src/desktop/LayoutSystem.ts @@ -271,12 +271,17 @@ export class LayoutStore { getCardsInCircle(x: number, y: number, radius: number): LayoutCard[] { const result: LayoutCard[] = []; for (const card of this.items.values()) { - const dx = card.x - x; - const dy = card.y - y; + // Calculate center of candidate card + const cx = card.x + card.width / 2; + const cy = card.y + card.height / 2; + + const dx = cx - x; + const dy = cy - y; - // Use squared distance to avoid sqrt const distSq = dx * dx + dy * dy; - if (distSq < radius * radius) { + const limit = radius; + + if (distSq < limit * limit) { result.push(card); } } @@ -284,7 +289,9 @@ export class LayoutStore { } getStackBelow(topCard: LayoutCard): string[] { - const candidates = this.getCardsInCircle(topCard.x, topCard.y, topCard.innerRadius); + const centerX = topCard.x + topCard.width / 2; + const centerY = topCard.y + topCard.height / 2; + const candidates = this.getCardsInCircle(centerX, centerY, topCard.innerRadius); return candidates .filter(other => {