fix(ui): a side of a midpoint block thinner than 8% of the window holds no panel; pin the lower merge edge

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 23:14:26 -08:00
1 parent 378df7b613
commit 10dbd2f937
5 files changed
+22 -6

No files matched your search

+2
View File
@@ -169,6 +169,8 @@ export function layoutLeftPanelRail({
bottom: safeBottom,
obstacles: inLane,
gap: safeGap,
// A side thinner than this holds no usable panel.
minimum: viewportHeight * 0.08,
});
if (beside) {
obstacleSafeTop = beside.top;
+8 -2
View File
@@ -56,6 +56,8 @@ export function resolveHudRailLayout({
bottom: Math.min(viewportHeight, baseBottom),
obstacles: inLane,
gap,
// A side thinner than this holds no usable panel.
minimum: viewportHeight * 0.08,
});
if (beside) ({ top: safeTop, bottom: safeBottom } = beside);
@@ -86,6 +88,8 @@ export function resolveHudRailLayout({
* @param {number} input.bottom The band's lowest bottom.
* @param {Array<{top: number, bottom: number}>} input.obstacles Rectangles that reach the rail.
* @param {number} input.gap Space kept between the band and an obstacle.
* @param {number} [input.minimum=0] The least room a side needs to count;
* a thinner side is no room at all.
* @returns {{side: 'above' | 'below', top: number, bottom: number} | null}
* Null when nothing crosses the midpoint or neither side has room.
*/
@@ -95,6 +99,7 @@ export function bandBesideMidpointObstacles({
bottom,
obstacles,
gap,
minimum = 0,
}) {
const crossing = obstacles.filter(
(rect) => rect.top < midpoint && rect.bottom > midpoint,
@@ -134,8 +139,9 @@ export function bandBesideMidpointObstacles({
};
const roomAbove = above.bottom - above.top;
const roomBelow = below.bottom - below.top;
if (roomBelow > roomAbove && roomBelow > 0) return below;
return roomAbove > 0 ? above : null;
const least = Math.max(minimum, Number.EPSILON);
if (roomBelow > roomAbove && roomBelow >= least) return below;
return roomAbove >= least ? above : null;
}
/**
+4 -3
View File
@@ -268,14 +268,15 @@ test('the left corridor counts cards beside those across the midpoint', () => {
];
f.run();
assert(Number(f.stack.dataset.safeTopPct) * 4.8 >= 300);
// Only a little room above the cards: the corridor stays there rather
// than run down through the lower one.
// About 25px above the cards is under the least usable room (8% of the
// window): they are read as before, the upper card pushing the corridor
// down past it rather than into a sliver at the top.
f.options.obstacles = [
element('card', { top: 50, height: 150 }),
element('card', { top: 150, height: 320 }),
];
f.run();
assert(Number(f.stack.dataset.safeBottomPct) * 4.8 <= 50);
assert(Number(f.stack.dataset.safeTopPct) * 4.8 >= 200);
// The room above a card is all the panels' to use, above the corridor's
// usual top (26%) too: 700px window, card 300 to 420, about 263px above
// against 244 below.