mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
fix(web): face editor respects detail panel bounds and preserves position on resize
This commit is contained in:
@@ -487,8 +487,6 @@
|
|||||||
class="fixed start-0 top-0 grid size-full grid-cols-4 grid-rows-[64px_1fr] overflow-hidden bg-black"
|
class="fixed start-0 top-0 grid size-full grid-cols-4 grid-rows-[64px_1fr] overflow-hidden bg-black"
|
||||||
use:focusTrap
|
use:focusTrap
|
||||||
bind:this={assetViewerHtmlElement}
|
bind:this={assetViewerHtmlElement}
|
||||||
bind:clientWidth={containerWidth}
|
|
||||||
bind:clientHeight={containerHeight}
|
|
||||||
>
|
>
|
||||||
<!-- Top navigation bar -->
|
<!-- Top navigation bar -->
|
||||||
{#if $slideshowState === SlideshowState.None && !assetViewerManager.isShowEditor}
|
{#if $slideshowState === SlideshowState.None && !assetViewerManager.isShowEditor}
|
||||||
@@ -530,7 +528,12 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<!-- Asset Viewer -->
|
<!-- Asset Viewer -->
|
||||||
<div data-viewer-content class="z-[-1] relative col-start-1 col-span-4 row-start-1 row-span-full">
|
<div
|
||||||
|
data-viewer-content
|
||||||
|
class="z-[-1] relative col-start-1 col-span-4 row-start-1 row-span-full"
|
||||||
|
bind:clientWidth={containerWidth}
|
||||||
|
bind:clientHeight={containerHeight}
|
||||||
|
>
|
||||||
{#if viewerKind === 'StackVideoViewer'}
|
{#if viewerKind === 'StackVideoViewer'}
|
||||||
<VideoViewer
|
<VideoViewer
|
||||||
asset={previewStackedAsset!}
|
asset={previewStackedAsset!}
|
||||||
|
|||||||
@@ -31,6 +31,10 @@
|
|||||||
|
|
||||||
let searchTerm = $state('');
|
let searchTerm = $state('');
|
||||||
let faceBoxPosition = $state({ left: 0, top: 0, width: 0, height: 0 });
|
let faceBoxPosition = $state({ left: 0, top: 0, width: 0, height: 0 });
|
||||||
|
let initialized = false;
|
||||||
|
let previousContentWidth = 0;
|
||||||
|
let previousOffsetX = 0;
|
||||||
|
let previousOffsetY = 0;
|
||||||
|
|
||||||
let filteredCandidates = $derived(
|
let filteredCandidates = $derived(
|
||||||
searchTerm
|
searchTerm
|
||||||
@@ -94,27 +98,49 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
const { offsetX, offsetY } = imageContentMetrics;
|
const { offsetX, offsetY, contentWidth } = imageContentMetrics;
|
||||||
|
|
||||||
if (!canvas) {
|
if (!canvas || contentWidth === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.setDimensions({
|
if (!initialized) {
|
||||||
width: containerWidth,
|
initialized = true;
|
||||||
height: containerHeight,
|
canvas.setDimensions({ width: containerWidth, height: containerHeight });
|
||||||
});
|
|
||||||
|
|
||||||
if (!faceRect) {
|
if (faceRect) {
|
||||||
|
faceRect.set({ top: offsetY + 200, left: offsetX + 200 });
|
||||||
|
faceRect.setCoords();
|
||||||
|
}
|
||||||
|
|
||||||
|
previousContentWidth = contentWidth;
|
||||||
|
previousOffsetX = offsetX;
|
||||||
|
previousOffsetY = offsetY;
|
||||||
|
positionFaceSelector();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
faceRect.set({
|
canvas.setDimensions({ width: containerWidth, height: containerHeight });
|
||||||
top: offsetY + 200,
|
|
||||||
left: offsetX + 200,
|
|
||||||
});
|
|
||||||
|
|
||||||
faceRect.setCoords();
|
if (faceRect && previousContentWidth > 0) {
|
||||||
|
const scale = contentWidth / previousContentWidth;
|
||||||
|
const imageRelLeft = (faceRect.left - previousOffsetX) * scale;
|
||||||
|
const imageRelTop = (faceRect.top - previousOffsetY) * scale;
|
||||||
|
|
||||||
|
faceRect.set({
|
||||||
|
left: offsetX + imageRelLeft,
|
||||||
|
top: offsetY + imageRelTop,
|
||||||
|
scaleX: faceRect.scaleX * scale,
|
||||||
|
scaleY: faceRect.scaleY * scale,
|
||||||
|
});
|
||||||
|
faceRect.setCoords();
|
||||||
|
}
|
||||||
|
|
||||||
|
previousContentWidth = contentWidth;
|
||||||
|
previousOffsetX = offsetX;
|
||||||
|
previousOffsetY = offsetY;
|
||||||
|
|
||||||
|
canvas.renderAll();
|
||||||
positionFaceSelector();
|
positionFaceSelector();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user