refactor: centralize multi-card bring-to-front logic and document new spatial workspace architecture.

This commit is contained in:
2025-11-26 17:52:14 +01:00
parent 835dcc4faa
commit 9a3ed74230
2 changed files with 34 additions and 7 deletions
+14 -1
View File
@@ -274,7 +274,6 @@ export class LayoutStore {
const dx = card.x - x;
const dy = card.y - y;
// Check if center is within inner radius of top card
// Use squared distance to avoid sqrt
const distSq = dx * dx + dy * dy;
if (distSq < radius * radius) {
@@ -296,6 +295,20 @@ export class LayoutStore {
.map(c => c.id);
}
bringToFront(ids: string[]) {
const cards = ids
.map(id => this.items.get(id))
.filter((c): c is LayoutCard => !!c);
// Sort by current Z-index to preserve relative order
cards.sort((a, b) => a.z - b.z);
// Assign new Z-indices
for (const card of cards) {
card.update({ z: this.zCounter++ });
}
}
getSnapshot() {
return Array.from(this.items.values()).map(card => card.toSnapshot());
}