2025-06-02 04:06:48 +02:00
|
|
|
import { photoZoomState } from '$lib/stores/zoom-image.store';
|
2024-06-07 14:22:46 -04:00
|
|
|
import { useZoomImageWheel } from '@zoom-image/svelte';
|
|
|
|
|
import { get } from 'svelte/store';
|
|
|
|
|
|
|
|
|
|
export const zoomImageAction = (node: HTMLElement) => {
|
|
|
|
|
const { createZoomImage, zoomImageState, setZoomImageState } = useZoomImageWheel();
|
|
|
|
|
|
|
|
|
|
createZoomImage(node, {
|
|
|
|
|
maxZoom: 10,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const state = get(photoZoomState);
|
|
|
|
|
if (state) {
|
|
|
|
|
setZoomImageState(state);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-02 04:06:48 +02:00
|
|
|
const unsubscribes = [photoZoomState.subscribe(setZoomImageState), zoomImageState.subscribe(photoZoomState.set)];
|
2024-06-07 14:22:46 -04:00
|
|
|
return {
|
|
|
|
|
destroy() {
|
|
|
|
|
for (const unsubscribe of unsubscribes) {
|
|
|
|
|
unsubscribe();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|