Add items-with-image theme

This commit is contained in:
Pieter Vander Vennet 2024-02-21 18:47:12 +01:00
parent 894d857cdc
commit 894c48520a
9 changed files with 163 additions and 7 deletions

View file

@ -71,7 +71,7 @@ class SingleBackgroundHandler {
this.fadeOut()
} else {
this._deactivationTime = undefined
this.enable()
await this.enable()
this.fadeIn()
}
}
@ -85,10 +85,23 @@ class SingleBackgroundHandler {
}
}
private enable() {
private async enable(){
let ttl = 15
await this.awaitStyleIsLoaded()
while(!this.tryEnable() && ttl > 0){
ttl --;
await Utils.waitFor(250)
}
}
/**
* Returns 'false' if should be attempted again
* @private
*/
private tryEnable(): boolean {
const map: MLMap = this._map.data
if (!map) {
return
return true
}
const background = this._targetLayer.properties
console.debug("Enabling", background.id)
@ -101,8 +114,7 @@ class SingleBackgroundHandler {
try {
map.addSource(background.id, RasterLayerHandler.prepareWmsSource(background))
} catch (e) {
console.error("Could not add source", e)
return
return false
}
}
if (!map.getLayer(background.id)) {
@ -126,6 +138,7 @@ class SingleBackgroundHandler {
map.setPaintProperty(background.id, "raster-opacity", o)
})
}
return true
}
private fadeOut() {