fix(builder): forzar auto-orden restaurante al detectar solape vertical

This commit is contained in:
komkida91
2026-03-01 14:32:45 +01:00
parent 10d8fb8cae
commit d18a92d017

View File

@@ -2992,25 +2992,20 @@ const state = {
id: b.id, id: b.id,
x: Number(b.pos.x), x: Number(b.pos.x),
y: Number(b.pos.y), y: Number(b.pos.y),
w: Math.max(30, Math.min(100, Number(b?.data?.width || 60))),
h: estimateFreeDragBlockHeight(b) h: estimateFreeDragBlockHeight(b)
})); }));
if (list.length < 2) return false; if (list.length < 2) return false;
const ordered = list.slice().sort((a, b)=>a.y - b.y);
let overlaps = 0; let overlaps = 0;
for (let i = 0; i < list.length; i++){ for (let i = 0; i < ordered.length - 1; i++){
for (let j = i + 1; j < list.length; j++){ const curr = ordered[i];
const a = list[i]; const next = ordered[i + 1];
const b = list[j]; const sameLane = Math.abs(curr.x - next.x) <= 180;
const ax2 = a.x + a.w; const currBottom = curr.y + curr.h;
const bx2 = b.x + b.w; const verticalOverlap = next.y < (currBottom - 24);
const ay2 = a.y + a.h; if (sameLane && verticalOverlap){
const by2 = b.y + b.h; overlaps += 1;
const xOverlap = Math.min(ax2, bx2) - Math.max(a.x, b.x); if (overlaps >= 1) return true;
const yOverlap = Math.min(ay2, by2) - Math.max(a.y, b.y);
if (xOverlap > 6 && yOverlap > 20){
overlaps += 1;
if (overlaps >= 2) return true;
}
} }
} }
return false; return false;