From 728233bf86efbfc46d840c7bdf8727fb02285487 Mon Sep 17 00:00:00 2001 From: martabal <74269598+martabal@users.noreply.github.com> Date: Sat, 2 Dec 2023 02:25:10 +0100 Subject: [PATCH] fix: zoom & rotation --- web/src/app.d.ts | 1 + .../asset-viewer/asset-viewer-nav-bar.svelte | 2 +- .../asset-viewer/asset-viewer.svelte | 18 +++++++----------- .../asset-viewer/photo-viewer.svelte | 16 +++++++++------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/web/src/app.d.ts b/web/src/app.d.ts index 241a579fc..c2e471a4a 100644 --- a/web/src/app.d.ts +++ b/web/src/app.d.ts @@ -25,5 +25,6 @@ declare namespace svelteHTML { interface HTMLAttributes { 'on:copyImage'?: () => void; 'on:zoomImage'?: () => void; + 'on:rotateImage'?: () => void; } } diff --git a/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte b/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte index d72d05b03..2f9e50009 100644 --- a/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte +++ b/web/src/lib/components/asset-viewer/asset-viewer-nav-bar.svelte @@ -183,7 +183,7 @@ text={asset.isArchived ? 'Unarchive' : 'Archive'} /> onMenuClick('asProfileImage')} text="As profile picture" /> - onMenuClick('rotate')} text="Rotate left" /> + onMenuClick('rotate')} text="Rotate right" /> {#if hasStackChildren} onMenuClick('unstack')} text="Un-Stack" /> {/if} diff --git a/web/src/lib/components/asset-viewer/asset-viewer.svelte b/web/src/lib/components/asset-viewer/asset-viewer.svelte index 2d45dbb52..0b92cab28 100644 --- a/web/src/lib/components/asset-viewer/asset-viewer.svelte +++ b/web/src/lib/components/asset-viewer/asset-viewer.svelte @@ -55,7 +55,6 @@ export let album: AlbumResponseDto | null = null; let reactions: ActivityResponseDto[] = []; - let rotatePhotoviewer: () => Promise; const { setAssetId } = assetViewingStore; const { restartProgress: restartSlideshowProgress, @@ -256,6 +255,11 @@ isShowActivity = !isShowActivity; }; + const handleRotate = () => { + const rotateImage = new CustomEvent('rotateImage'); + window.dispatchEvent(rotateImage); + }; + const handleKeyboardPress = (event: KeyboardEvent) => { if (shouldIgnoreShortcut(event)) { return; @@ -307,9 +311,6 @@ } } }; - function handleRotate() { - rotatePhotoviewer(); - } const handleCloseViewer = () => { $isShowDetail = false; @@ -634,12 +635,7 @@ {#if previewStackedAsset} {#key previewStackedAsset.id} {#if previewStackedAsset.type === AssetTypeEnum.Image} - + {:else} {:else} - + {/if} {:else} { // switch (value) { @@ -55,8 +56,8 @@ } }; - export const rotate = async () => { - setZoomImageWheelState({ currentRotation: $zoomImageWheelState.currentRotation - 90 }); + const doRotate = async () => { + setZoomImageWheelState({ currentRotation: $zoomImageWheelState.currentRotation + 90 }); try { await api.assetApi.updateAsset({ id: asset.id, @@ -175,13 +176,14 @@ } - +
{#await loadAssetData({ loadOriginal: false })} @@ -193,7 +195,7 @@ alt={asset.id} class="h-full w-full object-contain" draggable="false" - style={`width:${imgWidth}px;height:${imgHeight}px;`} + style={`width:${imgWidth}px;height:${imgHeight}px;transform-origin: 0px 0px 0px;`} />
{/await}