forked from MapComplete/MapComplete
Fix: imagepreview: improve typing; fix comparison tool
This commit is contained in:
parent
a16bfac530
commit
6cb16877e8
4 changed files with 10 additions and 7 deletions
|
@ -137,7 +137,7 @@
|
||||||
<AttributedImage
|
<AttributedImage
|
||||||
{state}
|
{state}
|
||||||
imgClass="h-32 shrink-0"
|
imgClass="h-32 shrink-0"
|
||||||
image={{ url: image }}
|
image={{ url: image, id: image }}
|
||||||
previewedImage={state.previewedImage}
|
previewedImage={state.previewedImage}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
export let imgClass: string = undefined
|
export let imgClass: string = undefined
|
||||||
export let state: SpecialVisualizationState = undefined
|
export let state: SpecialVisualizationState = undefined
|
||||||
export let attributionFormat: "minimal" | "medium" | "large" = "medium"
|
export let attributionFormat: "minimal" | "medium" | "large" = "medium"
|
||||||
export let previewedImage: UIEventSource<ProvidedImage> = undefined
|
export let previewedImage: UIEventSource<Partial<ProvidedImage>> = undefined
|
||||||
export let canZoom = previewedImage !== undefined
|
export let canZoom = previewedImage !== undefined
|
||||||
let loaded = false
|
let loaded = false
|
||||||
let showBigPreview = new UIEventSource(false)
|
let showBigPreview = new UIEventSource(false)
|
||||||
|
@ -37,13 +37,13 @@
|
||||||
if (!shown) {
|
if (!shown) {
|
||||||
previewedImage?.set(undefined)
|
previewedImage?.set(undefined)
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
if (previewedImage) {
|
if (previewedImage) {
|
||||||
onDestroy(
|
onDestroy(
|
||||||
previewedImage.addCallbackAndRun((previewedImage) => {
|
previewedImage.addCallbackAndRun((previewedImage) => {
|
||||||
showBigPreview.set(previewedImage !== undefined && previewedImage?.id === image.id)
|
showBigPreview.set(previewedImage !== undefined && (previewedImage?.id ?? previewedImage?.url) === (image.id ?? image.url))
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +89,8 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Popup>
|
</Popup>
|
||||||
|
|
||||||
|
|
||||||
{#if image.status !== undefined && image.status !== "ready" && image.status !== "hidden"}
|
{#if image.status !== undefined && image.status !== "ready" && image.status !== "hidden"}
|
||||||
<div class="flex h-full flex-col justify-center">
|
<div class="flex h-full flex-col justify-center">
|
||||||
<Loading>
|
<Loading>
|
||||||
|
@ -113,6 +115,7 @@
|
||||||
class={imgClass ?? ""}
|
class={imgClass ?? ""}
|
||||||
class:cursor-zoom-in={canZoom}
|
class:cursor-zoom-in={canZoom}
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
console.log("Setting",image.url)
|
||||||
previewedImage?.set(image)
|
previewedImage?.set(image)
|
||||||
}}
|
}}
|
||||||
on:error={() => {
|
on:error={() => {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import Translations from "../i18n/Translations"
|
import Translations from "../i18n/Translations"
|
||||||
import DotMenu from "../Base/DotMenu.svelte"
|
import DotMenu from "../Base/DotMenu.svelte"
|
||||||
|
|
||||||
export let image: ProvidedImage
|
export let image: Partial<ProvidedImage> & ({ id: string, url: string })
|
||||||
export let clss: string = undefined
|
export let clss: string = undefined
|
||||||
|
|
||||||
let isLoaded = new UIEventSource(false)
|
let isLoaded = new UIEventSource(false)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import Zoomcontrol from "../Zoomcontrol"
|
import Zoomcontrol from "../Zoomcontrol"
|
||||||
import { onDestroy } from "svelte"
|
import { onDestroy } from "svelte"
|
||||||
|
|
||||||
export let image: ProvidedImage
|
export let image: Partial<ProvidedImage>
|
||||||
let panzoomInstance = undefined
|
let panzoomInstance = undefined
|
||||||
let panzoomEl: HTMLElement
|
let panzoomEl: HTMLElement
|
||||||
export let isLoaded: UIEventSource<boolean> = undefined
|
export let isLoaded: UIEventSource<boolean> = undefined
|
||||||
|
|
Loading…
Reference in a new issue