mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
fix: reset zoom when navigating between assets (#25863)
This commit is contained in:
parent
2990bde0bb
commit
5212bca3d0
2 changed files with 17 additions and 14 deletions
|
|
@ -55,13 +55,10 @@
|
||||||
|
|
||||||
let loader = $state<HTMLImageElement>();
|
let loader = $state<HTMLImageElement>();
|
||||||
|
|
||||||
assetViewerManager.zoomState = {
|
$effect.pre(() => {
|
||||||
currentRotation: 0,
|
void asset.id;
|
||||||
currentZoom: 1,
|
untrack(() => assetViewerManager.resetZoomState());
|
||||||
enable: true,
|
});
|
||||||
currentPositionX: 0,
|
|
||||||
currentPositionY: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
$boundingBoxesArray = [];
|
$boundingBoxesArray = [];
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,14 @@ import type { ZoomImageWheelState } from '@zoom-image/core';
|
||||||
|
|
||||||
const isShowDetailPanel = new PersistedLocalStorage<boolean>('asset-viewer-state', false);
|
const isShowDetailPanel = new PersistedLocalStorage<boolean>('asset-viewer-state', false);
|
||||||
|
|
||||||
|
const createDefaultZoomState = (): ZoomImageWheelState => ({
|
||||||
|
currentRotation: 0,
|
||||||
|
currentZoom: 1,
|
||||||
|
enable: true,
|
||||||
|
currentPositionX: 0,
|
||||||
|
currentPositionY: 0,
|
||||||
|
});
|
||||||
|
|
||||||
export type Events = {
|
export type Events = {
|
||||||
Zoom: [];
|
Zoom: [];
|
||||||
ZoomChange: [ZoomImageWheelState];
|
ZoomChange: [ZoomImageWheelState];
|
||||||
|
|
@ -12,13 +20,7 @@ export type Events = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export class AssetViewerManager extends BaseEventManager<Events> {
|
export class AssetViewerManager extends BaseEventManager<Events> {
|
||||||
#zoomState = $state<ZoomImageWheelState>({
|
#zoomState = $state(createDefaultZoomState());
|
||||||
currentRotation: 0,
|
|
||||||
currentZoom: 1,
|
|
||||||
enable: true,
|
|
||||||
currentPositionX: 0,
|
|
||||||
currentPositionY: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
imgRef = $state<HTMLImageElement | undefined>();
|
imgRef = $state<HTMLImageElement | undefined>();
|
||||||
isShowActivityPanel = $state(false);
|
isShowActivityPanel = $state(false);
|
||||||
|
|
@ -67,6 +69,10 @@ export class AssetViewerManager extends BaseEventManager<Events> {
|
||||||
this.#zoomState = state;
|
this.#zoomState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetZoomState() {
|
||||||
|
this.zoomState = createDefaultZoomState();
|
||||||
|
}
|
||||||
|
|
||||||
toggleActivityPanel() {
|
toggleActivityPanel() {
|
||||||
this.closeDetailPanel();
|
this.closeDetailPanel();
|
||||||
this.isShowActivityPanel = !this.isShowActivityPanel;
|
this.isShowActivityPanel = !this.isShowActivityPanel;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue