Fix: actually show HD image for nearby streetview imager, add loading indicator
This commit is contained in:
parent
6d8f1525b0
commit
8b6ee877f0
3 changed files with 16 additions and 3 deletions
|
@ -9,9 +9,13 @@
|
||||||
import { DownloadIcon } from "@rgossiaux/svelte-heroicons/solid"
|
import { DownloadIcon } from "@rgossiaux/svelte-heroicons/solid"
|
||||||
import { Utils } from "../../Utils"
|
import { Utils } from "../../Utils"
|
||||||
import { twMerge } from "tailwind-merge"
|
import { twMerge } from "tailwind-merge"
|
||||||
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||||
|
import Loading from "../Base/Loading.svelte"
|
||||||
|
|
||||||
export let image: ProvidedImage
|
export let image: ProvidedImage
|
||||||
export let clss: string = undefined
|
export let clss: string = undefined
|
||||||
|
|
||||||
|
let isLoaded = new UIEventSource(false)
|
||||||
async function download() {
|
async function download() {
|
||||||
const response = await fetch(image.url_hd ?? image.url)
|
const response = await fetch(image.url_hd ?? image.url)
|
||||||
const blob = await response.blob()
|
const blob = await response.blob()
|
||||||
|
@ -23,7 +27,12 @@
|
||||||
|
|
||||||
<div class={twMerge("relative h-full w-full", clss)}>
|
<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">
|
<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>
|
||||||
<div
|
<div
|
||||||
class="pointer-events-none absolute bottom-0 left-0 flex w-full flex-wrap items-end justify-between"
|
class="pointer-events-none absolute bottom-0 left-0 flex w-full flex-wrap items-end justify-between"
|
||||||
|
|
|
@ -4,10 +4,12 @@
|
||||||
*/
|
*/
|
||||||
import panzoom from "panzoom"
|
import panzoom from "panzoom"
|
||||||
import type { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
import type { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
||||||
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||||
|
|
||||||
export let image: ProvidedImage
|
export let image: ProvidedImage
|
||||||
let panzoomInstance = undefined
|
let panzoomInstance = undefined
|
||||||
let panzoomEl: HTMLElement
|
let panzoomEl: HTMLElement
|
||||||
|
export let isLoaded: UIEventSource<boolean> = undefined
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (panzoomEl) {
|
if (panzoomEl) {
|
||||||
|
@ -16,7 +18,7 @@
|
||||||
boundsPadding: 0.49,
|
boundsPadding: 0.49,
|
||||||
minZoom: 1,
|
minZoom: 1,
|
||||||
maxZoom: 25,
|
maxZoom: 25,
|
||||||
initialZoom: 1.2,
|
initialZoom: 1.0,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
panzoomInstance?.dispose()
|
panzoomInstance?.dispose()
|
||||||
|
@ -24,4 +26,5 @@
|
||||||
}
|
}
|
||||||
</script>
|
</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} />
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
const c = [lon, lat]
|
const c = [lon, lat]
|
||||||
const providedImage: ProvidedImage = {
|
const providedImage: ProvidedImage = {
|
||||||
url: image.thumbUrl ?? image.pictureUrl,
|
url: image.thumbUrl ?? image.pictureUrl,
|
||||||
|
url_hd: image.pictureUrl,
|
||||||
key: undefined,
|
key: undefined,
|
||||||
provider: AllImageProviders.byName(image.provider),
|
provider: AllImageProviders.byName(image.provider),
|
||||||
date: new Date(image.date),
|
date: new Date(image.date),
|
||||||
|
|
Loading…
Reference in a new issue