2023-12-05 18:35:18 +01:00
|
|
|
<script lang="ts">
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The image preview allows to drag and zoom in to the image
|
|
|
|
*/
|
2023-12-06 13:19:45 +01:00
|
|
|
import panzoom from "panzoom"
|
2023-12-05 18:35:18 +01:00
|
|
|
import type { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
|
|
|
|
|
|
|
export let image : ProvidedImage
|
|
|
|
let panzoomInstance = undefined
|
|
|
|
let panzoomEl: HTMLElement
|
|
|
|
|
|
|
|
$: {
|
|
|
|
if (panzoomEl) {
|
|
|
|
panzoomInstance = panzoom(panzoomEl, { bounds: true,
|
2023-12-06 17:27:30 +01:00
|
|
|
boundsPadding: 0.49,
|
2023-12-05 18:35:18 +01:00
|
|
|
minZoom: 1,
|
2023-12-06 13:47:20 +01:00
|
|
|
maxZoom: 25,
|
|
|
|
initialZoom: 1.2
|
2023-12-05 18:35:18 +01:00
|
|
|
})
|
|
|
|
} else {
|
|
|
|
panzoomInstance?.dispose()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
2023-12-07 01:04:43 +01:00
|
|
|
<img bind:this={panzoomEl} src={image.url_hd ?? image.url} class="w-full h-auto"/>
|