mirror of
https://github.com/immich-app/immich.git
synced 2025-12-12 15:50:43 -08:00
776 lines
25 KiB
Svelte
776 lines
25 KiB
Svelte
<script lang="ts">
|
|
import { goto } from '$app/navigation';
|
|
import { focusTrap } from '$lib/actions/focus-trap';
|
|
import type { Action, OnAction, PreAction } from '$lib/components/asset-viewer/actions/action';
|
|
import MotionPhotoAction from '$lib/components/asset-viewer/actions/motion-photo-action.svelte';
|
|
import NextAssetAction from '$lib/components/asset-viewer/actions/next-asset-action.svelte';
|
|
import PreviousAssetAction from '$lib/components/asset-viewer/actions/previous-asset-action.svelte';
|
|
import AssetViewerNavBar from '$lib/components/asset-viewer/asset-viewer-nav-bar.svelte';
|
|
import OnEvents from '$lib/components/OnEvents.svelte';
|
|
import { AppRoute, AssetAction, ProjectionType } from '$lib/constants';
|
|
import { activityManager } from '$lib/managers/activity-manager.svelte';
|
|
import { authManager } from '$lib/managers/auth-manager.svelte';
|
|
import { eventManager } from '$lib/managers/event-manager.svelte';
|
|
import { preloadManager } from '$lib/managers/PreloadManager.svelte';
|
|
import { viewTransitionManager } from '$lib/managers/ViewTransitionManager.svelte';
|
|
import { closeEditorCofirm } from '$lib/stores/asset-editor.store';
|
|
import { assetViewingStore } from '$lib/stores/asset-viewing.store';
|
|
import { ocrManager } from '$lib/stores/ocr.svelte';
|
|
import { alwaysLoadOriginalVideo, isShowDetail } from '$lib/stores/preferences.store';
|
|
import { SlideshowNavigation, SlideshowState, slideshowStore } from '$lib/stores/slideshow.store';
|
|
import { user } from '$lib/stores/user.store';
|
|
import { websocketEvents } from '$lib/stores/websocket';
|
|
import { resetZoomState } from '$lib/stores/zoom-image.store';
|
|
import { getAssetJobMessage, getAssetUrl, getSharedLink, handlePromiseError } from '$lib/utils';
|
|
import { handleError } from '$lib/utils/handle-error';
|
|
import { InvocationTracker } from '$lib/utils/invocationTracker';
|
|
import { SlideshowHistory } from '$lib/utils/slideshow-history';
|
|
import { preloadImageUrl } from '$lib/utils/sw-messaging';
|
|
import { toTimelineAsset } from '$lib/utils/timeline-util';
|
|
import {
|
|
AssetJobName,
|
|
AssetTypeEnum,
|
|
getAllAlbums,
|
|
getAssetInfo,
|
|
getStack,
|
|
runAssetJobs,
|
|
type AlbumResponseDto,
|
|
type AssetResponseDto,
|
|
type PersonResponseDto,
|
|
type StackResponseDto,
|
|
} from '@immich/sdk';
|
|
import { toastManager } from '@immich/ui';
|
|
import { onDestroy, onMount, untrack } from 'svelte';
|
|
import { t } from 'svelte-i18n';
|
|
import { fly, slide } from 'svelte/transition';
|
|
import Thumbnail from '../assets/thumbnail/thumbnail.svelte';
|
|
import ActivityStatus from './activity-status.svelte';
|
|
import ActivityViewer from './activity-viewer.svelte';
|
|
import DetailPanel from './detail-panel.svelte';
|
|
import CropArea from './editor/crop-tool/crop-area.svelte';
|
|
import EditorPanel from './editor/editor-panel.svelte';
|
|
import ImagePanoramaViewer from './image-panorama-viewer.svelte';
|
|
import OcrButton from './ocr-button.svelte';
|
|
import PhotoViewer from './photo-viewer.svelte';
|
|
import SlideshowBar from './slideshow-bar.svelte';
|
|
import VideoViewer from './video-wrapper-viewer.svelte';
|
|
|
|
interface Props {
|
|
asset: AssetResponseDto;
|
|
nextAsset?: AssetResponseDto;
|
|
previousAsset?: AssetResponseDto;
|
|
showNavigation?: boolean;
|
|
withStacked?: boolean;
|
|
isShared?: boolean;
|
|
album?: AlbumResponseDto | null;
|
|
person?: PersonResponseDto | null;
|
|
preAction?: PreAction | undefined;
|
|
onAction?: OnAction | undefined;
|
|
showCloseButton?: boolean;
|
|
onClose?: (asset: AssetResponseDto) => void;
|
|
onNavigateToAsset?: (asset: AssetResponseDto | undefined) => Promise<boolean>;
|
|
onRandom?: () => Promise<{ id: string } | undefined>;
|
|
copyImage?: () => Promise<void>;
|
|
}
|
|
|
|
let {
|
|
asset,
|
|
nextAsset,
|
|
previousAsset,
|
|
showNavigation = true,
|
|
withStacked = false,
|
|
isShared = false,
|
|
album = null,
|
|
person = null,
|
|
preAction = undefined,
|
|
onAction = undefined,
|
|
showCloseButton,
|
|
onClose,
|
|
onNavigateToAsset,
|
|
onRandom,
|
|
copyImage = $bindable(),
|
|
}: Props = $props();
|
|
|
|
const { setAssetId, invisible } = assetViewingStore;
|
|
const {
|
|
restartProgress: restartSlideshowProgress,
|
|
stopProgress: stopSlideshowProgress,
|
|
slideshowNavigation,
|
|
slideshowState,
|
|
slideshowTransition,
|
|
} = slideshowStore;
|
|
const stackThumbnailSize = 60;
|
|
const stackSelectedThumbnailSize = 65;
|
|
|
|
let appearsInAlbums: AlbumResponseDto[] = $state([]);
|
|
let shouldPlayMotionPhoto = $state(false);
|
|
let sharedLink = getSharedLink();
|
|
let enableDetailPanel = asset.hasMetadata;
|
|
let slideshowStateUnsubscribe: () => void;
|
|
let shuffleSlideshowUnsubscribe: () => void;
|
|
let previewStackedAsset: AssetResponseDto | undefined = $state();
|
|
let isShowActivity = $state(false);
|
|
let isShowEditor = $state(false);
|
|
let fullscreenElement = $state<Element>();
|
|
let unsubscribes: (() => void)[] = [];
|
|
let selectedEditType: string = $state('');
|
|
let stack: StackResponseDto | null = $state(null);
|
|
|
|
let zoomToggle = $state(() => void 0);
|
|
let playOriginalVideo = $state($alwaysLoadOriginalVideo);
|
|
|
|
const setPlayOriginalVideo = (value: boolean) => {
|
|
playOriginalVideo = value;
|
|
};
|
|
|
|
const refreshStack = async () => {
|
|
if (authManager.isSharedLink) {
|
|
return;
|
|
}
|
|
|
|
if (asset.stack) {
|
|
stack = await getStack({ id: asset.stack.id });
|
|
}
|
|
|
|
if (!stack?.assets.some(({ id }) => id === asset.id)) {
|
|
stack = null;
|
|
}
|
|
|
|
untrack(() => {
|
|
if (stack && stack?.assets.length > 1) {
|
|
preloadImageUrl(getAssetUrl({ asset: stack.assets[1] }));
|
|
}
|
|
});
|
|
};
|
|
|
|
const handleFavorite = async () => {
|
|
if (album && album.isActivityEnabled) {
|
|
try {
|
|
await activityManager.toggleLike();
|
|
} catch (error) {
|
|
handleError(error, $t('errors.unable_to_change_favorite'));
|
|
}
|
|
}
|
|
};
|
|
|
|
const onAssetUpdate = ({ asset: assetUpdate }: { event: 'upload' | 'update'; asset: AssetResponseDto }) => {
|
|
if (assetUpdate.id === asset.id) {
|
|
asset = assetUpdate;
|
|
}
|
|
};
|
|
|
|
let transitionName = $state<string | null>(null);
|
|
let equirectangularTransitionName = $state<string | null>();
|
|
let detailPanelTransitionName = $state<string | null>(null);
|
|
|
|
if (viewTransitionManager.activeViewTransition) {
|
|
transitionName = 'hero';
|
|
equirectangularTransitionName = 'hero';
|
|
}
|
|
let addInfoTransition;
|
|
let finished;
|
|
onMount(async () => {
|
|
addInfoTransition = () => {
|
|
detailPanelTransitionName = 'info';
|
|
};
|
|
eventManager.on('TransitionToAssetViewer', addInfoTransition);
|
|
eventManager.on('TransitionToTimeline', addInfoTransition);
|
|
finished = () => {
|
|
detailPanelTransitionName = null;
|
|
transitionName = null;
|
|
};
|
|
eventManager.on('Finished', finished);
|
|
// eventManager.emit('AssetViewerLoaded');
|
|
unsubscribes.push(
|
|
websocketEvents.on('on_upload_success', (asset) => onAssetUpdate({ event: 'upload', asset })),
|
|
websocketEvents.on('on_asset_update', (asset) => onAssetUpdate({ event: 'update', asset })),
|
|
);
|
|
|
|
slideshowStateUnsubscribe = slideshowState.subscribe((value) => {
|
|
if (value === SlideshowState.PlaySlideshow) {
|
|
slideshowHistory.reset();
|
|
slideshowHistory.queue(toTimelineAsset(asset));
|
|
handlePromiseError(handlePlaySlideshow());
|
|
} else if (value === SlideshowState.StopSlideshow) {
|
|
handlePromiseError(handleStopSlideshow());
|
|
}
|
|
});
|
|
|
|
shuffleSlideshowUnsubscribe = slideshowNavigation.subscribe((value) => {
|
|
if (value === SlideshowNavigation.Shuffle) {
|
|
slideshowHistory.reset();
|
|
slideshowHistory.queue(toTimelineAsset(asset));
|
|
}
|
|
});
|
|
|
|
if (!sharedLink) {
|
|
await handleGetAllAlbums();
|
|
}
|
|
});
|
|
|
|
onDestroy(() => {
|
|
if (slideshowStateUnsubscribe) {
|
|
slideshowStateUnsubscribe();
|
|
}
|
|
|
|
if (shuffleSlideshowUnsubscribe) {
|
|
shuffleSlideshowUnsubscribe();
|
|
}
|
|
|
|
for (const unsubscribe of unsubscribes) {
|
|
unsubscribe();
|
|
}
|
|
|
|
activityManager.reset();
|
|
eventManager.off('TransitionToAssetViewer', addInfoTransition!);
|
|
eventManager.off('TransitionToTimeline', addInfoTransition!);
|
|
eventManager.off('Finished', finished!);
|
|
});
|
|
|
|
const handleGetAllAlbums = async () => {
|
|
if (authManager.isSharedLink) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
appearsInAlbums = await getAllAlbums({ assetId: asset.id });
|
|
} catch (error) {
|
|
console.error('Error getting album that asset belong to', error);
|
|
}
|
|
};
|
|
|
|
const handleOpenActivity = () => {
|
|
if ($isShowDetail) {
|
|
$isShowDetail = false;
|
|
}
|
|
isShowActivity = !isShowActivity;
|
|
};
|
|
|
|
const toggleDetailPanel = () => {
|
|
isShowActivity = false;
|
|
$isShowDetail = !$isShowDetail;
|
|
};
|
|
|
|
const closeViewer = () => {
|
|
transitionName = 'hero';
|
|
onClose?.(asset);
|
|
};
|
|
|
|
const closeEditor = () => {
|
|
closeEditorCofirm(() => {
|
|
isShowEditor = false;
|
|
});
|
|
};
|
|
|
|
const startTransition = (targetTransition: string | null, targetAsset?: AssetResponseDto) => {
|
|
transitionName = targetTransition;
|
|
equirectangularTransitionName = targetTransition;
|
|
detailPanelTransitionName = 'onTop';
|
|
|
|
viewTransitionManager.startTransition(
|
|
new Promise<void>((resolve) => {
|
|
eventManager.once('StartViewTransition', () => {
|
|
if (targetAsset && isEquirectangular(asset) && !isEquirectangular(targetAsset)) {
|
|
equirectangularTransitionName = null;
|
|
}
|
|
});
|
|
eventManager.once('AssetViewerFree', () => resolve());
|
|
}),
|
|
);
|
|
};
|
|
|
|
const tracker = new InvocationTracker();
|
|
|
|
const navigateAsset = (order?: 'previous' | 'next', skipTransition?: boolean = false) => {
|
|
if (!order) {
|
|
if ($slideshowState === SlideshowState.PlaySlideshow) {
|
|
order = $slideshowNavigation === SlideshowNavigation.AscendingOrder ? 'previous' : 'next';
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (tracker.isActive()) {
|
|
return;
|
|
}
|
|
|
|
void tracker.invoke(async () => {
|
|
let hasNext = false;
|
|
|
|
if ($slideshowState === SlideshowState.PlaySlideshow && $slideshowNavigation === SlideshowNavigation.Shuffle) {
|
|
if (!skipTransition) {
|
|
startTransition(null, undefined);
|
|
}
|
|
hasNext = order === 'previous' ? slideshowHistory.previous() : slideshowHistory.next();
|
|
if (!hasNext) {
|
|
const asset = await onRandom?.();
|
|
if (asset) {
|
|
slideshowHistory.queue(asset);
|
|
hasNext = true;
|
|
}
|
|
}
|
|
} else if (onNavigateToAsset) {
|
|
// only transition if the target is already preloaded, and is in a secure context
|
|
const targetAsset = order === 'previous' ? previousAsset : nextAsset;
|
|
if (!skipTransition && !!targetAsset && globalThis.isSecureContext && preloadManager.isPreloaded(targetAsset)) {
|
|
const targetTransition = $slideshowState === SlideshowState.PlaySlideshow ? null : order;
|
|
startTransition(targetTransition, targetAsset);
|
|
}
|
|
resetZoomState();
|
|
hasNext = order === 'previous' ? await onNavigateToAsset(previousAsset) : await onNavigateToAsset(nextAsset);
|
|
} else {
|
|
hasNext = false;
|
|
}
|
|
|
|
if ($slideshowState === SlideshowState.PlaySlideshow) {
|
|
if (hasNext) {
|
|
$restartSlideshowProgress = true;
|
|
} else {
|
|
await handleStopSlideshow();
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
const handleRunJob = async (name: AssetJobName) => {
|
|
try {
|
|
await runAssetJobs({ assetJobsDto: { assetIds: [asset.id], name } });
|
|
toastManager.success($getAssetJobMessage(name));
|
|
} catch (error) {
|
|
handleError(error, $t('errors.unable_to_submit_job'));
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Slide show mode
|
|
*/
|
|
|
|
let assetViewerHtmlElement = $state<HTMLElement>();
|
|
|
|
const slideshowHistory = new SlideshowHistory((asset) => {
|
|
handlePromiseError(setAssetId(asset.id).then(() => ($restartSlideshowProgress = true)));
|
|
});
|
|
|
|
const handleVideoStarted = () => {
|
|
if ($slideshowState === SlideshowState.PlaySlideshow) {
|
|
$stopSlideshowProgress = true;
|
|
}
|
|
};
|
|
|
|
const handlePlaySlideshow = async () => {
|
|
try {
|
|
await assetViewerHtmlElement?.requestFullscreen?.();
|
|
} catch (error) {
|
|
handleError(error, $t('errors.unable_to_enter_fullscreen'));
|
|
$slideshowState = SlideshowState.StopSlideshow;
|
|
}
|
|
};
|
|
|
|
const handleStopSlideshow = async () => {
|
|
try {
|
|
if (document.fullscreenElement) {
|
|
document.body.style.cursor = '';
|
|
await document.exitFullscreen();
|
|
}
|
|
} catch (error) {
|
|
handleError(error, $t('errors.unable_to_exit_fullscreen'));
|
|
} finally {
|
|
$stopSlideshowProgress = true;
|
|
$slideshowState = SlideshowState.None;
|
|
}
|
|
};
|
|
|
|
const handleStackedAssetMouseEvent = (isMouseOver: boolean, asset: AssetResponseDto) => {
|
|
previewStackedAsset = isMouseOver ? asset : undefined;
|
|
};
|
|
const handlePreAction = (action: Action) => {
|
|
preAction?.(action);
|
|
};
|
|
const handleAction = async (action: Action) => {
|
|
switch (action.type) {
|
|
case AssetAction.ADD_TO_ALBUM: {
|
|
await handleGetAllAlbums();
|
|
break;
|
|
}
|
|
case AssetAction.REMOVE_ASSET_FROM_STACK: {
|
|
stack = action.stack;
|
|
if (stack) {
|
|
asset = stack.assets[0];
|
|
}
|
|
break;
|
|
}
|
|
case AssetAction.STACK:
|
|
case AssetAction.SET_STACK_PRIMARY_ASSET: {
|
|
stack = action.stack;
|
|
break;
|
|
}
|
|
case AssetAction.SET_PERSON_FEATURED_PHOTO: {
|
|
const assetInfo = await getAssetInfo({ id: asset.id });
|
|
asset = { ...asset, people: assetInfo.people };
|
|
break;
|
|
}
|
|
case AssetAction.KEEP_THIS_DELETE_OTHERS:
|
|
case AssetAction.UNSTACK: {
|
|
closeViewer();
|
|
break;
|
|
}
|
|
}
|
|
|
|
onAction?.(action);
|
|
};
|
|
|
|
const handleUpdateSelectedEditType = (type: string) => {
|
|
selectedEditType = type;
|
|
};
|
|
|
|
const handleAssetReplace = async ({ oldAssetId, newAssetId }: { oldAssetId: string; newAssetId: string }) => {
|
|
if (oldAssetId !== asset.id) {
|
|
return;
|
|
}
|
|
|
|
await new Promise((promise) => setTimeout(promise, 500));
|
|
await goto(`${AppRoute.PHOTOS}/${newAssetId}`);
|
|
};
|
|
|
|
let isFullScreen = $derived(fullscreenElement !== null);
|
|
|
|
$effect(() => {
|
|
if (album && !album.isActivityEnabled && activityManager.commentCount === 0) {
|
|
isShowActivity = false;
|
|
}
|
|
});
|
|
$effect(() => {
|
|
if (album && isShared && asset.id) {
|
|
handlePromiseError(activityManager.init(album.id, asset.id));
|
|
}
|
|
});
|
|
|
|
let lastAsset: AssetResponseDto | undefined;
|
|
$effect(() => {
|
|
const refresh = async () => {
|
|
await refreshStack();
|
|
await handleGetAllAlbums();
|
|
ocrManager.clear();
|
|
if (!sharedLink) {
|
|
if (previewStackedAsset) {
|
|
await ocrManager.getAssetOcr(previewStackedAsset.id);
|
|
}
|
|
await ocrManager.getAssetOcr(asset.id);
|
|
}
|
|
};
|
|
handlePromiseError(refresh());
|
|
if (lastAsset?.id !== asset.id) {
|
|
preloadManager.cancel(lastAsset);
|
|
}
|
|
lastAsset = asset;
|
|
});
|
|
|
|
$effect(() => {
|
|
preloadManager.preload(nextAsset);
|
|
preloadManager.preload(previousAsset);
|
|
});
|
|
|
|
$effect(() => {
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
asset.id;
|
|
if (viewerKind !== 'PhotoViewer' && viewerKind !== 'ImagePanaramaViewer' && viewerKind !== 'VideoViewer') {
|
|
eventManager.emit('AssetViewerFree');
|
|
}
|
|
});
|
|
|
|
const isEquirectangular = (asset: AssetResponseDto) => {
|
|
return (
|
|
asset.exifInfo?.projectionType === ProjectionType.EQUIRECTANGULAR ||
|
|
(asset.originalPath && asset.originalPath.toLowerCase().endsWith('.insp'))
|
|
);
|
|
};
|
|
|
|
const viewerKind = $derived.by(() => {
|
|
if (previewStackedAsset) {
|
|
return asset.type === AssetTypeEnum.Image ? 'StackPhotoViewer' : 'StackVideoViewer';
|
|
}
|
|
if (asset.type === AssetTypeEnum.Image) {
|
|
if (shouldPlayMotionPhoto && asset.livePhotoVideoId) {
|
|
return 'LiveVideoViewer';
|
|
} else if (isEquirectangular(asset)) {
|
|
return 'ImagePanaramaViewer';
|
|
} else if (isShowEditor && selectedEditType === 'crop') {
|
|
return 'CropArea';
|
|
}
|
|
return 'PhotoViewer';
|
|
}
|
|
return 'VideoViewer';
|
|
});
|
|
</script>
|
|
|
|
<OnEvents onAssetReplace={handleAssetReplace} />
|
|
|
|
<svelte:document bind:fullscreenElement />
|
|
|
|
<section
|
|
id="immich-asset-viewer"
|
|
class="fixed start-0 top-0 grid size-full grid-cols-4 grid-rows-[64px_1fr] overflow-hidden bg-black"
|
|
class:invisible={$invisible}
|
|
use:focusTrap
|
|
bind:this={assetViewerHtmlElement}
|
|
>
|
|
<!-- Top navigation bar -->
|
|
{#if $slideshowState === SlideshowState.None && !isShowEditor}
|
|
<div
|
|
class="col-span-4 col-start-1 row-span-1 row-start-1 transition-transform"
|
|
style:view-transition-name="exclude"
|
|
>
|
|
<AssetViewerNavBar
|
|
{asset}
|
|
{album}
|
|
{person}
|
|
{stack}
|
|
{showCloseButton}
|
|
showDetailButton={enableDetailPanel}
|
|
showSlideshow={true}
|
|
onZoomImage={zoomToggle}
|
|
onCopyImage={copyImage}
|
|
preAction={handlePreAction}
|
|
onAction={handleAction}
|
|
onRunJob={handleRunJob}
|
|
onPlaySlideshow={() => ($slideshowState = SlideshowState.PlaySlideshow)}
|
|
onShowDetail={toggleDetailPanel}
|
|
onClose={closeViewer}
|
|
{playOriginalVideo}
|
|
{setPlayOriginalVideo}
|
|
>
|
|
{#snippet motionPhoto()}
|
|
<MotionPhotoAction
|
|
isPlaying={shouldPlayMotionPhoto}
|
|
onClick={(shouldPlay) => (shouldPlayMotionPhoto = shouldPlay)}
|
|
/>
|
|
{/snippet}
|
|
</AssetViewerNavBar>
|
|
</div>
|
|
{/if}
|
|
|
|
{#if $slideshowState != SlideshowState.None}
|
|
<div class="absolute w-full flex">
|
|
<SlideshowBar
|
|
{isFullScreen}
|
|
onSetToFullScreen={() => assetViewerHtmlElement?.requestFullscreen?.()}
|
|
onPrevious={() => navigateAsset('previous')}
|
|
onNext={() => navigateAsset('next')}
|
|
onClose={() => ($slideshowState = SlideshowState.StopSlideshow)}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
|
|
{#if $slideshowState === SlideshowState.None && showNavigation && !isShowEditor && previousAsset}
|
|
<div class="my-auto column-span-1 col-start-1 row-span-full row-start-1 justify-self-start">
|
|
<PreviousAssetAction onPreviousAsset={() => navigateAsset('previous')} />
|
|
</div>
|
|
{/if}
|
|
|
|
<!-- Asset Viewer -->
|
|
<div class="z-[-1] relative col-start-1 col-span-4 row-start-1 row-span-full items-center flex">
|
|
{#if viewerKind === 'StackPhotoViewer'}
|
|
<PhotoViewer
|
|
bind:zoomToggle
|
|
bind:copyImage
|
|
{transitionName}
|
|
asset={previewStackedAsset!}
|
|
{nextAsset}
|
|
{previousAsset}
|
|
onPreviousAsset={() => navigateAsset('previous', true)}
|
|
onNextAsset={() => navigateAsset('next', true)}
|
|
{sharedLink}
|
|
/>
|
|
{:else if viewerKind === 'StackVideoViewer'}
|
|
<VideoViewer
|
|
{transitionName}
|
|
assetId={previewStackedAsset!.id}
|
|
cacheKey={previewStackedAsset!.thumbhash}
|
|
projectionType={previewStackedAsset!.exifInfo?.projectionType}
|
|
loopVideo={true}
|
|
onPreviousAsset={() => navigateAsset('previous')}
|
|
onNextAsset={() => navigateAsset('next')}
|
|
onClose={closeViewer}
|
|
onVideoEnded={() => navigateAsset()}
|
|
onVideoStarted={handleVideoStarted}
|
|
{playOriginalVideo}
|
|
/>
|
|
{:else if viewerKind === 'LiveVideoViewer'}
|
|
<VideoViewer
|
|
{transitionName}
|
|
assetId={asset.livePhotoVideoId!}
|
|
cacheKey={asset.thumbhash}
|
|
projectionType={asset.exifInfo?.projectionType}
|
|
loopVideo={$slideshowState !== SlideshowState.PlaySlideshow}
|
|
onPreviousAsset={() => navigateAsset('previous')}
|
|
onNextAsset={() => navigateAsset('next')}
|
|
onVideoEnded={() => (shouldPlayMotionPhoto = false)}
|
|
{playOriginalVideo}
|
|
/>
|
|
{:else if viewerKind === 'ImagePanaramaViewer'}
|
|
<ImagePanoramaViewer bind:zoomToggle {asset} transitionName={equirectangularTransitionName} />
|
|
{:else if viewerKind === 'CropArea'}
|
|
<CropArea {asset} />
|
|
{:else if viewerKind === 'PhotoViewer'}
|
|
<PhotoViewer
|
|
{transitionName}
|
|
bind:zoomToggle
|
|
bind:copyImage
|
|
{asset}
|
|
{nextAsset}
|
|
{previousAsset}
|
|
onPreviousAsset={() => navigateAsset('previous', true)}
|
|
onNextAsset={() => navigateAsset('next', true)}
|
|
{sharedLink}
|
|
onFree={() => eventManager.emit('AssetViewerFree')}
|
|
/>
|
|
{:else if viewerKind === 'VideoViewer'}
|
|
<VideoViewer
|
|
{transitionName}
|
|
assetId={asset.id}
|
|
cacheKey={asset.thumbhash}
|
|
projectionType={asset.exifInfo?.projectionType}
|
|
loopVideo={$slideshowState !== SlideshowState.PlaySlideshow}
|
|
onPreviousAsset={() => navigateAsset('previous')}
|
|
onNextAsset={() => navigateAsset('next')}
|
|
onClose={closeViewer}
|
|
onVideoEnded={() => navigateAsset()}
|
|
onVideoStarted={handleVideoStarted}
|
|
{playOriginalVideo}
|
|
/>
|
|
{/if}
|
|
|
|
{#if $slideshowState === SlideshowState.None && isShared && ((album && album.isActivityEnabled) || activityManager.commentCount > 0) && !activityManager.isLoading}
|
|
<div class="absolute bottom-0 end-0 mb-20 me-8">
|
|
<ActivityStatus
|
|
disabled={!album?.isActivityEnabled}
|
|
isLiked={activityManager.isLiked}
|
|
numberOfComments={activityManager.commentCount}
|
|
numberOfLikes={activityManager.likeCount}
|
|
onFavorite={handleFavorite}
|
|
onOpenActivityTab={handleOpenActivity}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
|
|
{#if $slideshowState === SlideshowState.None && asset.type === AssetTypeEnum.Image && !isShowEditor && ocrManager.hasOcrData}
|
|
<div class="absolute bottom-0 end-0 mb-6 me-6">
|
|
<OcrButton />
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
{#if $slideshowState === SlideshowState.None && showNavigation && !isShowEditor && nextAsset}
|
|
<div class="my-auto col-span-1 col-start-4 row-span-full row-start-1 justify-self-end">
|
|
<NextAssetAction onNextAsset={() => navigateAsset('next')} />
|
|
</div>
|
|
{/if}
|
|
|
|
{#if enableDetailPanel && $slideshowState === SlideshowState.None && $isShowDetail && !isShowEditor}
|
|
<div
|
|
transition:slide={{ axis: 'x', duration: 150 }}
|
|
id="detail-panel"
|
|
style:view-transition-name={detailPanelTransitionName}
|
|
class="row-start-1 row-span-4 w-[360px] overflow-y-auto transition-all dark:border-l dark:border-s-immich-dark-gray bg-light"
|
|
translate="yes"
|
|
>
|
|
<DetailPanel {asset} currentAlbum={album} albums={appearsInAlbums} onClose={() => ($isShowDetail = false)} />
|
|
</div>
|
|
{/if}
|
|
|
|
{#if isShowEditor}
|
|
<div
|
|
transition:fly={{ duration: 150 }}
|
|
id="editor-panel"
|
|
class="row-start-1 row-span-4 w-[400px] overflow-y-auto transition-all dark:border-l dark:border-s-immich-dark-gray"
|
|
translate="yes"
|
|
>
|
|
<EditorPanel {asset} onUpdateSelectedType={handleUpdateSelectedEditType} onClose={closeEditor} />
|
|
</div>
|
|
{/if}
|
|
|
|
{#if stack && withStacked}
|
|
{@const stackedAssets = stack.assets}
|
|
<div id="stack-slideshow" class="absolute bottom-0 w-full col-span-4 col-start-1">
|
|
<div class="relative flex flex-row no-wrap overflow-x-auto overflow-y-hidden horizontal-scrollbar">
|
|
{#each stackedAssets as stackedAsset (stackedAsset.id)}
|
|
<div
|
|
class={['inline-block px-1 relative transition-all pb-2']}
|
|
style:bottom={stackedAsset.id === asset.id ? '0' : '-10px'}
|
|
>
|
|
<Thumbnail
|
|
imageClass={{ 'border-2 border-white': stackedAsset.id === asset.id }}
|
|
brokenAssetClass="text-xs"
|
|
dimmed={stackedAsset.id !== asset.id}
|
|
asset={toTimelineAsset(stackedAsset)}
|
|
onClick={() => {
|
|
asset = stackedAsset;
|
|
previewStackedAsset = undefined;
|
|
}}
|
|
onMouseEvent={({ isMouseOver }) => handleStackedAssetMouseEvent(isMouseOver, stackedAsset)}
|
|
readonly
|
|
thumbnailSize={stackedAsset.id === asset.id ? stackSelectedThumbnailSize : stackThumbnailSize}
|
|
showStackedIcon={false}
|
|
disableLinkMouseOver
|
|
/>
|
|
|
|
{#if stackedAsset.id === asset.id}
|
|
<div class="w-full flex place-items-center place-content-center">
|
|
<div class="w-2 h-2 bg-white rounded-full flex mt-0.5"></div>
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
{/each}
|
|
</div>
|
|
</div>
|
|
{/if}
|
|
|
|
{#if isShared && album && isShowActivity && $user}
|
|
<div
|
|
transition:fly={{ duration: 150 }}
|
|
id="activity-panel"
|
|
class="row-start-1 row-span-5 w-[360px] md:w-[460px] overflow-y-auto transition-all dark:border-l dark:border-s-immich-dark-gray"
|
|
translate="yes"
|
|
>
|
|
<ActivityViewer
|
|
user={$user}
|
|
disabled={!album.isActivityEnabled}
|
|
assetType={asset.type}
|
|
albumOwnerId={album.ownerId}
|
|
albumId={album.id}
|
|
assetId={asset.id}
|
|
onClose={() => (isShowActivity = false)}
|
|
/>
|
|
</div>
|
|
{/if}
|
|
</section>
|
|
|
|
<style>
|
|
#immich-asset-viewer {
|
|
contain: layout;
|
|
}
|
|
|
|
.horizontal-scrollbar::-webkit-scrollbar {
|
|
width: 8px;
|
|
height: 10px;
|
|
}
|
|
|
|
/* Track */
|
|
.horizontal-scrollbar::-webkit-scrollbar-track {
|
|
background: #000000;
|
|
border-radius: 16px;
|
|
}
|
|
|
|
/* Handle */
|
|
.horizontal-scrollbar::-webkit-scrollbar-thumb {
|
|
background: rgba(159, 159, 159, 0.408);
|
|
border-radius: 16px;
|
|
}
|
|
|
|
/* Handle on hover */
|
|
.horizontal-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
background: #adcbfa;
|
|
border-radius: 16px;
|
|
}
|
|
</style>
|