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