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,
|
|
|
|
boundsPadding: 1,
|
|
|
|
minZoom: 1,
|
|
|
|
maxZoom: 25
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
panzoomInstance?.dispose()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
2023-12-06 13:19:45 +01:00
|
|
|
<img bind:this={panzoomEl} src={image.url}/>
|