Drive on other screens (field test on a 26″): the cells at most the profile's 80 px, on a bigger screen only the map's columns and rows stretch (the right column, the menus and the map keys stay cell-sized, a list shows more rows), on a smaller one everything — cells, type, icons — scaled by one factor so a 7″ keeps the same elements; a menu now lies over the cells of the area it opens in (Next stop and the rest covered Terrain), the dials sized by the cell; the simulation's roll and pitch always from the terrain under it, not the IMU of the car standing at home; the dashboard's card over the map hidden while driving (Terrain instead)
This commit is contained in:
1 parent
f73badd107
commit
d39e3b5edd
4 files changed
+84
-64
No files matched your search
+16
-3
@@ -503,13 +503,26 @@ export function setupDriving(map, nightButton, routePanel, gpxPanel) {
|
||||
|
||||
fetch(PROFILE_URL, { cache: "no-cache" }).then((r) => r.json()).then((p) => {
|
||||
profile = p;
|
||||
app.style.setProperty("--drive-cols", p.columns);
|
||||
app.style.setProperty("--drive-rows", p.rows);
|
||||
// Cells of p.cell px at most; on a bigger screen only the map's columns
|
||||
// and rows (beside an open menu) stretch, the rest stays cell-sized.
|
||||
const [mr1, mc1, mr2, mc2] = p.menu.map.split("/").map(Number);
|
||||
const track = (n, from, to) => Array.from({ length: n }, (_, i) => (i + 1 >= from && i + 1 < to ? "minmax(0, 1fr)" : "var(--cell)")).join(" ");
|
||||
// One scale for everything (--s): the cells, the type, the icons — the
|
||||
// same elements on a 7″ as on the 16″, only smaller; never bigger than drawn.
|
||||
const fit = () => {
|
||||
const scale = Math.min(1, window.innerWidth / (p.columns * (p.cell || 80)), window.innerHeight / (p.rows * (p.cell || 80)));
|
||||
app.style.setProperty("--s", scale.toFixed(3));
|
||||
app.style.setProperty("--cell", `${((p.cell || 80) * scale).toFixed(1)}px`);
|
||||
};
|
||||
fit();
|
||||
window.addEventListener("resize", fit);
|
||||
app.style.setProperty("--drive-columns", track(p.columns, mc1, mc2));
|
||||
app.style.setProperty("--drive-row-sizes", track(p.rows, mr1, mr2));
|
||||
app.style.setProperty("--drive-map", openPanel ? p.menu.map : p.map);
|
||||
app.style.setProperty("--drive-menu", p.menu.area);
|
||||
const [r1, c1, r2, c2] = p.menu.area.split("/").map(Number);
|
||||
app.style.setProperty("--drive-menu-cols", c2 - c1);
|
||||
app.style.setProperty("--drive-menu-rows", r2 - r1);
|
||||
app.style.setProperty("--drive-menu-mid", r2 - r1 - 4); // the list rows between the 3 on top and the foot
|
||||
for (const cell of p.cells) {
|
||||
const el = make(cell);
|
||||
app.append(el);
|
||||
|
||||
Reference in new issue
Block a user