feat: zoom image improvements for reactive prop handlings (#25286)

This commit is contained in:
Min Idzelis
2026-01-20 07:18:54 -05:00
committed by GitHub
parent 2b4e4051f0
commit ca0d4b283a
2 changed files with 40 additions and 25 deletions
+23 -2
View File
@@ -1,4 +1,25 @@
import type { ZoomImageWheelState } from '@zoom-image/core';
import { writable } from 'svelte/store';
import { derived, writable } from 'svelte/store';
export const photoZoomState = writable<ZoomImageWheelState>();
export const photoZoomState = writable<ZoomImageWheelState>({
currentRotation: 0,
currentZoom: 1,
enable: true,
currentPositionX: 0,
currentPositionY: 0,
});
export const photoZoomTransform = derived(
photoZoomState,
($state) => `translate(${$state.currentPositionX}px,${$state.currentPositionY}px) scale(${$state.currentZoom})`,
);
export const resetZoomState = () => {
photoZoomState.set({
currentRotation: 0,
currentZoom: 1,
enable: true,
currentPositionX: 0,
currentPositionY: 0,
});
};