mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
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:
1 parent
378df7b613
commit
10dbd2f937
5 files changed
+22
-6
No files matched your search
@@ -1204,7 +1204,8 @@ block has more room up to the next obstacle, above it on a tie, whatever
|
||||
order the obstacles come in (`bandBesideMidpointObstacles` in
|
||||
`src/ui/panelRailGeometry.js`); on the left rail the panels may then rise
|
||||
above the corridor's usual top to use all the room above. With no room on
|
||||
either side the obstacles are read as before.
|
||||
either side (a side under 8% of the window's height counts as none) the
|
||||
obstacles are read as before.
|
||||
|
||||
Wind appears in the Weather group before Audio. The surface-weather prototype
|
||||
uses keyless NOAA GFS or ECMWF IFS forecasts on an approximately 1° display grid.
|
||||
|
||||
@@ -390,6 +390,12 @@ test('HUD rail layout counts obstacles beside those across the midpoint', () =>
|
||||
// Neighbours exactly two gaps away leave no room between: one block, 100
|
||||
// to 400, and a tie (50px a side) goes above.
|
||||
assert.deepEqual(band([[100, 180], [200, 300], [320, 400]]), [40, 90]);
|
||||
// A neighbour exactly two gaps below joins it too: 150 to 300, 110px
|
||||
// above against 150 below.
|
||||
assert.deepEqual(band([[150, 250], [270, 300]]), [310, 460]);
|
||||
// A side under 8% of the window (38.4px) is no room: 30px above, none
|
||||
// below, so the band stays as it is.
|
||||
assert.deepEqual(band([[80, 455]]), [40, 460]);
|
||||
});
|
||||
|
||||
test('HUD rail layout keeps a band beside a midpoint obstacle inside its own edges', () => {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user