refactor: centralize multi-card bring-to-front logic and document new spatial workspace architecture.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user