Phones: the legend's credit fold keeps looking until the credit is compact

An engine can mark its credit compact only after the map is ready, and the
fold stopped polling at a credit that was present but not yet compact, so
on such a map the credit never folded. It now stops only once the credit is
compact and already folded (a drag or a tap got there first), and keeps
looking, for up to 30 s as before, while it is not yet compact.
This commit is contained in:
Doxa Maps 2026-09-30 10:18:26 +00:00
parent cba3b0a872
commit 4116582bc9

View file

@ -868,8 +868,8 @@ onBeforeUnmount(() => {
// map's first drag. On a phone that drag may never come, and the expanded credit then runs across the top of
// the map for good, under the map's own top overlays. So CREDIT_FOLD_MS after it first shows expanded, fold it the way the engine's drag does (drop the
// -compact-show class); a tap on the (i) still expands it. The map may still be loading its style when the
// sheet mounts, so look every half second, for up to 30 s; stop once the credit is there and folded (a drag
// or a tap got there first) or is not compact at this width.
// sheet mounts, and an engine may mark it compact only after the map is ready, so look every half second, for
// up to 30 s; stop once the credit is compact and folded (a drag or a tap got there first).
const CREDIT_FOLD_MS = 3000
let _creditTimer = 0
function watchCredit(triesLeft) {
@ -883,7 +883,7 @@ function watchCredit(triesLeft) {
return
}
const credit = root.querySelector('.maplibregl-ctrl-attrib, .mapboxgl-ctrl-attrib')
if (credit && !/attrib-empty/.test(credit.className)) return
if (credit && /(maplibregl|mapboxgl)-compact(\s|$)/.test(credit.className)) return
if (triesLeft > 0) _creditTimer = setTimeout(() => watchCredit(triesLeft - 1), 500)
}
onMounted(() => watchCredit(60))