mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 02:02:21 +00:00
Keep the HUD corners, the dock and a wrapped credit line apart at every width
The credit line now wraps at every width instead of running under the corner row, and right to left it takes the bottom right at every width. A small watcher keeps its height in --credit-line-height, so the coordinates (and, right to left, the Tactical readout) stay above it however many lines it wraps onto, and the dock and World Timeline rise when it is taller than their usual clearance. Narrower than 1120px the dock leaves no room between the bottom corners, so the coordinates and the readout sit above the dock instead of under it. Outside the Omnibar layout, the coordinate rule meant for 981 to 1199px no longer overrides the two-row dock's placement at 980px and below. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
8ed14efdbf
commit
c69a421678
10 files changed
+288
-60
No files matched your search
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @module ui/creditLineHeight
|
||||
* @description Keeps `--credit-line-height` on the page's root at the
|
||||
* height of the attribution line at the bottom of the screen, so what sits
|
||||
* above it (the HUD's bottom corners) clears it when it wraps onto more
|
||||
* lines. The line is the application's own (`#gev-credits`) or the one a
|
||||
* renderer draws inside `#cesium-credits`.
|
||||
*/
|
||||
|
||||
const LINES = ['#gev-credits', '#cesium-credits .cesium-widget-credits'];
|
||||
|
||||
/**
|
||||
* Follow the attribution line's height in `--credit-line-height`.
|
||||
* @param {Document} [doc]
|
||||
* @returns {() => void} Stops following it and clears the property.
|
||||
*/
|
||||
export function trackCreditLineHeight(doc = globalThis.document) {
|
||||
const Observer = doc?.defaultView?.ResizeObserver;
|
||||
if (!doc?.documentElement || typeof Observer !== 'function') return () => {};
|
||||
const root = doc.documentElement;
|
||||
const lines = LINES.map((selector) => doc.querySelector(selector)).filter(
|
||||
Boolean,
|
||||
);
|
||||
if (!lines.length) return () => {};
|
||||
const update = () => {
|
||||
const height = Math.max(
|
||||
0,
|
||||
...lines.map((line) => line.getBoundingClientRect().height),
|
||||
);
|
||||
if (height > 0)
|
||||
root.style.setProperty('--credit-line-height', `${Math.ceil(height)}px`);
|
||||
else root.style.removeProperty('--credit-line-height');
|
||||
};
|
||||
const observer = new Observer(update);
|
||||
for (const line of lines) observer.observe(line);
|
||||
update();
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
root.style.removeProperty('--credit-line-height');
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user