mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
fix(ui): rails count the obstacles beside those across the middle, and read them as before when neither side has room
Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
feedd88614
commit
98a100ed7e
6 files changed
+146
-50
No files matched your search
+19
-26
@@ -5,6 +5,7 @@ import {
|
||||
resolvePanelStackCorridor,
|
||||
} from '../panelStackLayout.js';
|
||||
import { measurePanelNaturalHeight } from './panelMeasurement.js';
|
||||
import { bandBesideMidpointObstacles } from './panelRailGeometry.js';
|
||||
import { settleSideAccordion } from './panelAccordion.js';
|
||||
|
||||
/**
|
||||
@@ -118,10 +119,7 @@ export function layoutLeftPanelRail({
|
||||
let safeTop = baseTop;
|
||||
let safeBottom = viewportHeight - baseBottomInset;
|
||||
const bottomObstacles = [];
|
||||
// Obstacles across the midpoint all cover it, so together they cover one
|
||||
// span: from the highest top to the lowest bottom.
|
||||
let spanTop = Infinity;
|
||||
let spanBottom = -Infinity;
|
||||
const inLane = [];
|
||||
|
||||
for (const obstacle of obstacles) {
|
||||
if (stack.contains(obstacle)) continue;
|
||||
@@ -151,35 +149,30 @@ export function layoutLeftPanelRail({
|
||||
);
|
||||
if (!overlapsHorizontally) continue;
|
||||
|
||||
inLane.push(rect);
|
||||
if (rect.top < baseTop && rect.bottom <= viewportHeight * 0.5) {
|
||||
const obstacleBottom = rect.bottom + safeGap;
|
||||
obstacleSafeTop = Math.max(obstacleSafeTop, obstacleBottom);
|
||||
safeTop = Math.max(safeTop, obstacleBottom);
|
||||
} else if (
|
||||
rect.top < viewportHeight * 0.5 &&
|
||||
rect.bottom > viewportHeight * 0.5
|
||||
) {
|
||||
spanTop = Math.min(spanTop, rect.top);
|
||||
spanBottom = Math.max(spanBottom, rect.bottom);
|
||||
} else {
|
||||
} else if (rect.top >= baseTop) {
|
||||
bottomObstacles.push({ top: rect.top });
|
||||
}
|
||||
}
|
||||
// The panels go on whichever side of that span leaves more room (common in
|
||||
// short windows), above it on a tie. With no room on either side the
|
||||
// corridor stays as it is.
|
||||
if (spanBottom > spanTop) {
|
||||
const roomAbove = spanTop - safeGap - obstacleSafeTop;
|
||||
const lowerBottom = resolveLeftStackBottomBoundary({
|
||||
baseBottom: safeBottom,
|
||||
obstacles: bottomObstacles,
|
||||
safeGap,
|
||||
});
|
||||
const roomBelow = lowerBottom - (spanBottom + safeGap);
|
||||
if (roomBelow > roomAbove && roomBelow > 0) {
|
||||
obstacleSafeTop = Math.max(obstacleSafeTop, spanBottom + safeGap);
|
||||
safeTop = Math.max(safeTop, spanBottom + safeGap);
|
||||
} else if (roomAbove > 0) bottomObstacles.push({ top: spanTop });
|
||||
// Obstacles across the midpoint (common in short windows) put the panels
|
||||
// on whichever side of them has more room; with no room on either side the
|
||||
// obstacles are read as before.
|
||||
const beside = bandBesideMidpointObstacles({
|
||||
midpoint: viewportHeight * 0.5,
|
||||
top: viewportHeight * 0.04,
|
||||
bottom: safeBottom,
|
||||
obstacles: inLane,
|
||||
gap: safeGap,
|
||||
});
|
||||
if (beside) {
|
||||
obstacleSafeTop = beside.top;
|
||||
safeTop = Math.max(baseTop, beside.top);
|
||||
bottomObstacles.length = 0;
|
||||
bottomObstacles.push({ top: beside.bottom + safeGap });
|
||||
}
|
||||
safeBottom = resolveLeftStackBottomBoundary({
|
||||
baseBottom: safeBottom,
|
||||
|
||||
Reference in new issue
Block a user