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 => {