mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
* Fix an issue where clicking the zoom-button after having zoomed in would not zoom completely out, but leave the image in the zoomed-in state. The new behavior properly zoomes the image completely out after clicking the zoom-button. * Revert to the default setting for `wheelZoomRatio` as the previous setting of 0.2 was borderline unusable on a trackpad. This could probably be moved to a user setting if needed. * Add a keyboard shortcut 'z' to toggle image zoom.
25 lines
673 B
TypeScript
25 lines
673 B
TypeScript
import { photoZoomState } from '$lib/stores/zoom-image.store';
|
|
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);
|
|
}
|
|
|
|
const unsubscribes = [photoZoomState.subscribe(setZoomImageState), zoomImageState.subscribe(photoZoomState.set)];
|
|
return {
|
|
destroy() {
|
|
for (const unsubscribe of unsubscribes) {
|
|
unsubscribe();
|
|
}
|
|
},
|
|
};
|
|
};
|