Skip to content

High performance self-hosted photo and video management solution.

fix(web): show face name label above box when it would be hidden (#32088)

Joep Admiraal3f8cfe0b70ef
diff --git a/web/src/lib/components/asset-viewer/PhotoViewer.svelte b/web/src/lib/components/asset-viewer/PhotoViewer.svelte
index bdd02d7acb..468782ede2 100644
--- a/web/src/lib/components/asset-viewer/PhotoViewer.svelte
+++ b/web/src/lib/components/asset-viewer/PhotoViewer.svelte
@@ -61,6 +61,7 @@
let containerWidth = $state(0);
let containerHeight = $state(0);
+ const faceLabelOffset = 32;
const container = $derived({
width: containerWidth,
@@ -273,11 +274,14 @@
onpointerleave={() => assetViewerManager.clearHighlightedFaces()}
>
{#if isActive && boundingbox.name}
+ {@const labelAbove =
+ boundingbox.top + boundingbox.height + faceLabelOffset > overlaySize.height &&
+ boundingbox.top >= faceLabelOffset}
<div
aria-hidden="true"
class="absolute rounded-sm bg-white/90 px-2 py-1 text-sm font-medium whitespace-nowrap text-black shadow-lg"
bind:clientWidth={boundingbox.labelWidth}
- style="top: {boundingbox.height + 4}px; {assetViewerManager.imgRef
+ style="{labelAbove ? 'bottom' : 'top'}: {boundingbox.height + 4}px; {assetViewerManager.imgRef
? boundingbox.left >= boundingbox.labelWidth - boundingbox.width
? `right: ${Math.max(boundingbox.left + boundingbox.width - assetViewerManager.imgRef.clientWidth, 0)}px;`
: `left: ${-boundingbox.left}px;`