The credit's fold clock starts once the basemap credit has joined geoBoundaries

This commit is contained in:
Doxa Maps 2026-09-30 09:43:08 +00:00
parent bb145b5c1c
commit bd1239a496
2 changed files with 14 additions and 4 deletions

View file

@ -107,12 +107,17 @@ function foldCredit(triesLeft = 60) {
const box = mapEl.value
if (!box) return
const shown = box.querySelector('.maplibregl-ctrl-attrib.maplibregl-compact-show, .mapboxgl-ctrl-attrib.mapboxgl-compact-show')
if (shown) {
// The clock starts once the STYLE's own credit has joined geoBoundaries (it arrives with the style's
// sources), so the first expanded show names the basemap too; measured, the fold otherwise came while
// only "geoBoundaries" had shown. After 30 s it starts anyway.
const inner = shown && shown.querySelector('.maplibregl-ctrl-attrib-inner, .mapboxgl-ctrl-attrib-inner')
const full = !!(inner && inner.textContent.replace('geoBoundaries', '').replace(/[|\s]/g, '').length)
if (shown && (full || triesLeft <= 0)) {
creditTimer = setTimeout(() => { creditTimer = 0; shown.classList.remove('maplibregl-compact-show', 'mapboxgl-compact-show') }, CREDIT_FOLD_MS)
return
}
const credit = box.querySelector('.maplibregl-ctrl-attrib, .mapboxgl-ctrl-attrib')
if (credit && !/attrib-empty/.test(credit.className)) return
if (!shown && credit && !/attrib-empty/.test(credit.className)) return
if (triesLeft > 0) creditTimer = setTimeout(() => foldCredit(triesLeft - 1), 500)
}
function addCompactCredit(map, gl) {

View file

@ -150,12 +150,17 @@ function foldCredit(triesLeft = 60) {
const box = mapEl.value
if (!box) return
const shown = box.querySelector('.maplibregl-ctrl-attrib.maplibregl-compact-show, .mapboxgl-ctrl-attrib.mapboxgl-compact-show')
if (shown) {
// The clock starts once the STYLE's own credit has joined geoBoundaries (it arrives with the style's
// sources), so the first expanded show names the basemap too; measured, the fold otherwise came while
// only "geoBoundaries" had shown. After 30 s it starts anyway.
const inner = shown && shown.querySelector('.maplibregl-ctrl-attrib-inner, .mapboxgl-ctrl-attrib-inner')
const full = !!(inner && inner.textContent.replace('geoBoundaries', '').replace(/[|\s]/g, '').length)
if (shown && (full || triesLeft <= 0)) {
creditTimer = setTimeout(() => { creditTimer = 0; shown.classList.remove('maplibregl-compact-show', 'mapboxgl-compact-show') }, CREDIT_FOLD_MS)
return
}
const credit = box.querySelector('.maplibregl-ctrl-attrib, .mapboxgl-ctrl-attrib')
if (credit && !/attrib-empty/.test(credit.className)) return
if (!shown && credit && !/attrib-empty/.test(credit.className)) return
if (triesLeft > 0) creditTimer = setTimeout(() => foldCredit(triesLeft - 1), 500)
}
function addCompactCredit(map, gl) {