WIP: Keep mobile place selection centered

The map centering helpers gated their mobile branch on `sheetInsetPx > 0`,
but the inset is published on a deferred animation frame and is briefly 0
during a sheet-to-sheet transition. On mobile that skipped the mobile branch
and fell into the desktop sidebar branch, which shifts the map center left to
make room for the sidebar and pushed the selected pin to the right edge.

Make the mobile and desktop branches mutually exclusive by viewport so the
desktop logic can never run on mobile; with a 0 inset the mobile math is a
no-op and the existing sheet-snap re-pan corrects the vertical position once
the sheet publishes its height.
This commit is contained in:
raucao committed 2026-11-30 17:49:20 +04:00
1 parent 0e099972f6
commit fabf2ffa50
1 file changed
+9 -4
+9 -4
View File
@@ -801,8 +801,11 @@ export default class MapComponent extends Component {
let targetCenter = coords;
// Check if mobile (width <= 768px matches CSS)
if (size[0] <= 768 && this.mapUi.sheetInsetPx > 0) {
// Mobile (width <= 768px matches CSS). The desktop sidebar branch below
// must never run here: it shifts the map center left to make room for the
// sidebar, which pushes the pin to the right edge on a phone. `inset` is 0
// until the sheet publishes its height, which is fine — it just centers.
if (size[0] <= 768) {
const height = size[1];
const inset = this.mapUi.sheetInsetPx;
const headerEl = document.querySelector('.app-header');
@@ -878,8 +881,10 @@ export default class MapComponent extends Component {
const headerEl = document.querySelector('.app-header');
const headerHeight = headerEl ? headerEl.offsetHeight : 60;
// 1. Mobile Bottom Sheet Logic (Screen <= 768px)
if (size[0] <= 768 && this.mapUi.sheetInsetPx > 0) {
// 1. Mobile Bottom Sheet Logic (Screen <= 768px). Always taken on mobile so
// the desktop sidebar branch (which shifts the pin right) can never run
// there, even before the sheet has published its inset.
if (size[0] <= 768) {
const height = size[1];
const inset = this.mapUi.sheetInsetPx;
const visibleHeight = height - inset;