Fix: actually show HD image for nearby streetview imager, add loading indicator

This commit is contained in:
Pieter Vander Vennet 2023-12-26 12:26:26 +01:00
parent 6d8f1525b0
commit 8b6ee877f0
3 changed files with 16 additions and 3 deletions

View file

@ -9,9 +9,13 @@
import { DownloadIcon } from "@rgossiaux/svelte-heroicons/solid"
import { Utils } from "../../Utils"
import { twMerge } from "tailwind-merge"
import { UIEventSource } from "../../Logic/UIEventSource"
import Loading from "../Base/Loading.svelte"
export let image: ProvidedImage
export let clss: string = undefined
let isLoaded = new UIEventSource(false)
async function download() {
const response = await fetch(image.url_hd ?? image.url)
const blob = await response.blob()
@ -23,7 +27,12 @@
<div class={twMerge("relative h-full w-full", clss)}>
<div class="panzoom-container focusable absolute top-0 left-0 h-full w-full overflow-hidden">
<ImagePreview {image} />
{#if !$isLoaded}
<div class="w-full h-full flex items-center justify-center">
<Loading/>
</div>
{/if}
<ImagePreview {image} {isLoaded}/>
</div>
<div
class="pointer-events-none absolute bottom-0 left-0 flex w-full flex-wrap items-end justify-between"

View file

@ -4,10 +4,12 @@
*/
import panzoom from "panzoom"
import type { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
import { UIEventSource } from "../../Logic/UIEventSource"
export let image: ProvidedImage
let panzoomInstance = undefined
let panzoomEl: HTMLElement
export let isLoaded: UIEventSource<boolean> = undefined
$: {
if (panzoomEl) {
@ -16,7 +18,7 @@
boundsPadding: 0.49,
minZoom: 1,
maxZoom: 25,
initialZoom: 1.2,
initialZoom: 1.0,
})
} else {
panzoomInstance?.dispose()
@ -24,4 +26,5 @@
}
</script>
<img bind:this={panzoomEl} src={image.url_hd ?? image.url} class="panzoom-image h-fit w-fit" />
<img bind:this={panzoomEl} class="panzoom-image h-fit w-fit" on:load={() => {isLoaded?.setData(true)}}
src={image.url_hd ?? image.url} />

View file

@ -29,6 +29,7 @@
const c = [lon, lat]
const providedImage: ProvidedImage = {
url: image.thumbUrl ?? image.pictureUrl,
url_hd: image.pictureUrl,
key: undefined,
provider: AllImageProviders.byName(image.provider),
date: new Date(image.date),