asset-viewer.svelte 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. <script lang="ts">
  2. import { goto } from '$app/navigation';
  3. import {
  4. ActivityResponseDto,
  5. AlbumResponseDto,
  6. api,
  7. AssetJobName,
  8. AssetResponseDto,
  9. AssetTypeEnum,
  10. ReactionType,
  11. SharedLinkResponseDto,
  12. UserResponseDto,
  13. } from '@api';
  14. import { createEventDispatcher, onDestroy, onMount } from 'svelte';
  15. import { fly } from 'svelte/transition';
  16. import AlbumSelectionModal from '../shared-components/album-selection-modal.svelte';
  17. import { notificationController, NotificationType } from '../shared-components/notification/notification';
  18. import AssetViewerNavBar from './asset-viewer-nav-bar.svelte';
  19. import DetailPanel from './detail-panel.svelte';
  20. import PhotoViewer from './photo-viewer.svelte';
  21. import VideoViewer from './video-viewer.svelte';
  22. import PanoramaViewer from './panorama-viewer.svelte';
  23. import { ProjectionType } from '$lib/constants';
  24. import ConfirmDialogue from '$lib/components/shared-components/confirm-dialogue.svelte';
  25. import ProfileImageCropper from '../shared-components/profile-image-cropper.svelte';
  26. import { isShowDetail } from '$lib/stores/preferences.store';
  27. import { addAssetsToAlbum, downloadFile, getAssetType } from '$lib/utils/asset-utils';
  28. import NavigationArea from './navigation-area.svelte';
  29. import { browser } from '$app/environment';
  30. import { handleError } from '$lib/utils/handle-error';
  31. import type { AssetStore } from '$lib/stores/assets.store';
  32. import CircleIconButton from '../elements/buttons/circle-icon-button.svelte';
  33. import ProgressBar, { ProgressBarStatus } from '../shared-components/progress-bar/progress-bar.svelte';
  34. import { shouldIgnoreShortcut } from '$lib/utils/shortcut';
  35. import { featureFlags } from '$lib/stores/server-config.store';
  36. import {
  37. mdiChevronLeft,
  38. mdiHeartOutline,
  39. mdiHeart,
  40. mdiCommentOutline,
  41. mdiChevronRight,
  42. mdiClose,
  43. mdiImageBrokenVariant,
  44. mdiPause,
  45. mdiPlay,
  46. } from '@mdi/js';
  47. import Icon from '$lib/components/elements/icon.svelte';
  48. import Thumbnail from '../assets/thumbnail/thumbnail.svelte';
  49. import { stackAssetsStore } from '$lib/stores/stacked-asset.store';
  50. import ActivityViewer from './activity-viewer.svelte';
  51. export let assetStore: AssetStore | null = null;
  52. export let asset: AssetResponseDto;
  53. export let showNavigation = true;
  54. export let sharedLink: SharedLinkResponseDto | undefined = undefined;
  55. $: isTrashEnabled = $featureFlags.trash;
  56. export let force = false;
  57. export let withStacked = false;
  58. export let isShared = true;
  59. export let user: UserResponseDto | null = null;
  60. export let album: AlbumResponseDto | null = null;
  61. let reactions: ActivityResponseDto[] = [];
  62. const dispatch = createEventDispatcher<{
  63. archived: AssetResponseDto;
  64. unarchived: AssetResponseDto;
  65. favorite: AssetResponseDto;
  66. unfavorite: AssetResponseDto;
  67. close: void;
  68. next: void;
  69. previous: void;
  70. unstack: void;
  71. }>();
  72. let appearsInAlbums: AlbumResponseDto[] = [];
  73. let isShowAlbumPicker = false;
  74. let isShowDeleteConfirmation = false;
  75. let addToSharedAlbum = true;
  76. let shouldPlayMotionPhoto = false;
  77. let isShowProfileImageCrop = false;
  78. let shouldShowDownloadButton = sharedLink ? sharedLink.allowDownload : !asset.isOffline;
  79. let shouldShowDetailButton = asset.hasMetadata;
  80. let canCopyImagesToClipboard: boolean;
  81. let previewStackedAsset: AssetResponseDto | undefined;
  82. let isShowActivity = false;
  83. let isLiked: ActivityResponseDto | null = null;
  84. let numberOfComments: number;
  85. $: {
  86. if (asset.stackCount && asset.stack) {
  87. $stackAssetsStore = asset.stack;
  88. $stackAssetsStore = [...$stackAssetsStore, asset].sort(
  89. (a, b) => new Date(b.fileCreatedAt).getTime() - new Date(a.fileCreatedAt).getTime(),
  90. );
  91. }
  92. if (!$stackAssetsStore.map((a) => a.id).includes(asset.id)) {
  93. $stackAssetsStore = [];
  94. }
  95. }
  96. const handleFavorite = async () => {
  97. if (album) {
  98. try {
  99. if (isLiked) {
  100. const activityId = isLiked.id;
  101. await api.activityApi.deleteActivity({ id: activityId });
  102. reactions = reactions.filter((reaction) => reaction.id !== activityId);
  103. isLiked = null;
  104. } else {
  105. const { data } = await api.activityApi.createActivity({
  106. activityCreateDto: { albumId: album.id, assetId: asset.id, type: ReactionType.Like },
  107. });
  108. isLiked = data;
  109. reactions = [...reactions, isLiked];
  110. }
  111. } catch (error) {
  112. handleError(error, "Can't change favorite for asset");
  113. }
  114. }
  115. };
  116. const getFavorite = async () => {
  117. if (album && user) {
  118. try {
  119. const { data } = await api.activityApi.getActivities({
  120. userId: user.id,
  121. assetId: asset.id,
  122. albumId: album.id,
  123. type: ReactionType.Like,
  124. });
  125. if (data.length > 0) {
  126. isLiked = data[0];
  127. }
  128. } catch (error) {
  129. handleError(error, "Can't get Favorite");
  130. }
  131. }
  132. };
  133. const getNumberOfComments = async () => {
  134. if (album) {
  135. try {
  136. const { data } = await api.activityApi.getActivityStatistics({ assetId: asset.id, albumId: album.id });
  137. numberOfComments = data.comments;
  138. } catch (error) {
  139. handleError(error, "Can't get number of comments");
  140. }
  141. }
  142. };
  143. $: {
  144. if (isShared && asset.id) {
  145. getFavorite();
  146. getNumberOfComments();
  147. }
  148. }
  149. const onKeyboardPress = (keyInfo: KeyboardEvent) => handleKeyboardPress(keyInfo);
  150. onMount(async () => {
  151. document.addEventListener('keydown', onKeyboardPress);
  152. if (!sharedLink) {
  153. await getAllAlbums();
  154. }
  155. // Import hack :( see https://github.com/vadimkorr/svelte-carousel/issues/27#issuecomment-851022295
  156. // TODO: Move to regular import once the package correctly supports ESM.
  157. const module = await import('copy-image-clipboard');
  158. canCopyImagesToClipboard = module.canCopyImagesToClipboard();
  159. if (asset.stackCount && asset.stack) {
  160. $stackAssetsStore = asset.stack;
  161. $stackAssetsStore = [...$stackAssetsStore, asset].sort(
  162. (a, b) => new Date(a.fileCreatedAt).getTime() - new Date(b.fileCreatedAt).getTime(),
  163. );
  164. } else {
  165. $stackAssetsStore = [];
  166. }
  167. });
  168. onDestroy(() => {
  169. if (browser) {
  170. document.removeEventListener('keydown', onKeyboardPress);
  171. }
  172. });
  173. $: asset.id && !sharedLink && getAllAlbums(); // Update the album information when the asset ID changes
  174. const getAllAlbums = async () => {
  175. if (api.isSharedLink) {
  176. return;
  177. }
  178. try {
  179. const { data } = await api.albumApi.getAllAlbums({ assetId: asset.id });
  180. appearsInAlbums = data;
  181. } catch (e) {
  182. console.error('Error getting album that asset belong to', e);
  183. }
  184. };
  185. const handleOpenActivity = () => {
  186. if ($isShowDetail) {
  187. $isShowDetail = false;
  188. }
  189. isShowActivity = !isShowActivity;
  190. };
  191. const handleKeyboardPress = (event: KeyboardEvent) => {
  192. if (shouldIgnoreShortcut(event)) {
  193. return;
  194. }
  195. const key = event.key;
  196. const shiftKey = event.shiftKey;
  197. switch (key) {
  198. case 'a':
  199. case 'A':
  200. if (shiftKey) {
  201. toggleArchive();
  202. }
  203. return;
  204. case 'ArrowLeft':
  205. navigateAssetBackward();
  206. return;
  207. case 'ArrowRight':
  208. navigateAssetForward();
  209. return;
  210. case 'd':
  211. case 'D':
  212. if (shiftKey) {
  213. downloadFile(asset);
  214. }
  215. return;
  216. case 'Delete':
  217. trashOrDelete();
  218. return;
  219. case 'Escape':
  220. if (isShowDeleteConfirmation) {
  221. isShowDeleteConfirmation = false;
  222. return;
  223. }
  224. closeViewer();
  225. return;
  226. case 'f':
  227. toggleFavorite();
  228. return;
  229. case 'i':
  230. isShowActivity = false;
  231. $isShowDetail = !$isShowDetail;
  232. return;
  233. }
  234. };
  235. const handleCloseViewer = () => {
  236. $isShowDetail = false;
  237. closeViewer();
  238. };
  239. const closeViewer = () => dispatch('close');
  240. const navigateAssetForward = async (e?: Event) => {
  241. if (isSlideshowMode && assetStore && progressBar) {
  242. const hasNext = await assetStore.getNextAssetId(asset.id);
  243. if (hasNext) {
  244. progressBar.restart(true);
  245. } else {
  246. await handleStopSlideshow();
  247. }
  248. }
  249. e?.stopPropagation();
  250. dispatch('next');
  251. };
  252. const navigateAssetBackward = (e?: Event) => {
  253. if (isSlideshowMode && progressBar) {
  254. progressBar.restart(true);
  255. }
  256. e?.stopPropagation();
  257. dispatch('previous');
  258. };
  259. const showDetailInfoHandler = () => {
  260. if (isShowActivity) {
  261. isShowActivity = false;
  262. }
  263. $isShowDetail = !$isShowDetail;
  264. };
  265. $: trashOrDelete = !(force || !isTrashEnabled)
  266. ? trashAsset
  267. : () => {
  268. isShowDeleteConfirmation = true;
  269. };
  270. const trashAsset = async () => {
  271. try {
  272. await api.assetApi.deleteAssets({ assetBulkDeleteDto: { ids: [asset.id] } });
  273. await navigateAssetForward();
  274. assetStore?.removeAsset(asset.id);
  275. notificationController.show({
  276. message: 'Moved to trash',
  277. type: NotificationType.Info,
  278. });
  279. } catch (e) {
  280. handleError(e, 'Unable to trash asset');
  281. }
  282. };
  283. const deleteAsset = async () => {
  284. try {
  285. await api.assetApi.deleteAssets({ assetBulkDeleteDto: { ids: [asset.id], force: true } });
  286. await navigateAssetForward();
  287. assetStore?.removeAsset(asset.id);
  288. notificationController.show({
  289. message: 'Permanently deleted asset',
  290. type: NotificationType.Info,
  291. });
  292. } catch (e) {
  293. handleError(e, 'Unable to delete asset');
  294. } finally {
  295. isShowDeleteConfirmation = false;
  296. }
  297. };
  298. const toggleFavorite = async () => {
  299. try {
  300. const { data } = await api.assetApi.updateAsset({
  301. id: asset.id,
  302. updateAssetDto: {
  303. isFavorite: !asset.isFavorite,
  304. },
  305. });
  306. asset.isFavorite = data.isFavorite;
  307. assetStore?.updateAsset(data);
  308. dispatch(data.isFavorite ? 'favorite' : 'unfavorite', data);
  309. notificationController.show({
  310. type: NotificationType.Info,
  311. message: asset.isFavorite ? `Added to favorites` : `Removed from favorites`,
  312. });
  313. } catch (error) {
  314. await handleError(error, `Unable to ${asset.isFavorite ? `add asset to` : `remove asset from`} favorites`);
  315. }
  316. };
  317. const openAlbumPicker = (shared: boolean) => {
  318. isShowAlbumPicker = true;
  319. addToSharedAlbum = shared;
  320. };
  321. const handleAddToNewAlbum = (event: CustomEvent) => {
  322. isShowAlbumPicker = false;
  323. const { albumName }: { albumName: string } = event.detail;
  324. api.albumApi.createAlbum({ createAlbumDto: { albumName, assetIds: [asset.id] } }).then((response) => {
  325. const album = response.data;
  326. goto('/albums/' + album.id);
  327. });
  328. };
  329. const handleAddToAlbum = async (event: CustomEvent<{ album: AlbumResponseDto }>) => {
  330. isShowAlbumPicker = false;
  331. const album = event.detail.album;
  332. await addAssetsToAlbum(album.id, [asset.id]);
  333. await getAllAlbums();
  334. };
  335. const disableKeyDownEvent = () => {
  336. if (browser) {
  337. document.removeEventListener('keydown', onKeyboardPress);
  338. }
  339. };
  340. const enableKeyDownEvent = () => {
  341. if (browser) {
  342. document.addEventListener('keydown', onKeyboardPress);
  343. }
  344. };
  345. const toggleArchive = async () => {
  346. try {
  347. const { data } = await api.assetApi.updateAsset({
  348. id: asset.id,
  349. updateAssetDto: {
  350. isArchived: !asset.isArchived,
  351. },
  352. });
  353. asset.isArchived = data.isArchived;
  354. assetStore?.updateAsset(data);
  355. dispatch(data.isArchived ? 'archived' : 'unarchived', data);
  356. notificationController.show({
  357. type: NotificationType.Info,
  358. message: asset.isArchived ? `Added to archive` : `Removed from archive`,
  359. });
  360. } catch (error) {
  361. await handleError(error, `Unable to ${asset.isArchived ? `add asset to` : `remove asset from`} archive`);
  362. }
  363. };
  364. const handleRunJob = async (name: AssetJobName) => {
  365. try {
  366. await api.assetApi.runAssetJobs({ assetJobsDto: { assetIds: [asset.id], name } });
  367. notificationController.show({ type: NotificationType.Info, message: api.getAssetJobMessage(name) });
  368. } catch (error) {
  369. await handleError(error, `Unable to submit job`);
  370. }
  371. };
  372. /**
  373. * Slide show mode
  374. */
  375. let isSlideshowMode = false;
  376. let assetViewerHtmlElement: HTMLElement;
  377. let progressBar: ProgressBar;
  378. let progressBarStatus: ProgressBarStatus;
  379. const handleVideoStarted = () => {
  380. if (isSlideshowMode) {
  381. progressBar.restart(false);
  382. }
  383. };
  384. const handleVideoEnded = async () => {
  385. if (isSlideshowMode) {
  386. await navigateAssetForward();
  387. }
  388. };
  389. const handlePlaySlideshow = async () => {
  390. try {
  391. await assetViewerHtmlElement.requestFullscreen();
  392. } catch (error) {
  393. console.error('Error entering fullscreen', error);
  394. } finally {
  395. isSlideshowMode = true;
  396. }
  397. };
  398. const handleStopSlideshow = async () => {
  399. try {
  400. await document.exitFullscreen();
  401. } catch (error) {
  402. console.error('Error exiting fullscreen', error);
  403. } finally {
  404. isSlideshowMode = false;
  405. progressBar.restart(false);
  406. }
  407. };
  408. const handleStackedAssetMouseEvent = (e: CustomEvent<{ isMouseOver: boolean }>, asset: AssetResponseDto) => {
  409. const { isMouseOver } = e.detail;
  410. if (isMouseOver) {
  411. previewStackedAsset = asset;
  412. } else {
  413. previewStackedAsset = undefined;
  414. }
  415. };
  416. const handleUnstack = async () => {
  417. try {
  418. const ids = $stackAssetsStore.map(({ id }) => id);
  419. await api.assetApi.updateAssets({ assetBulkUpdateDto: { ids, removeParent: true } });
  420. for (const child of $stackAssetsStore) {
  421. child.stackParentId = null;
  422. assetStore?.addAsset(child);
  423. }
  424. asset.stackCount = 0;
  425. asset.stack = [];
  426. assetStore?.updateAsset(asset);
  427. dispatch('unstack');
  428. notificationController.show({ type: NotificationType.Info, message: 'Un-stacked', timeout: 1500 });
  429. } catch (error) {
  430. await handleError(error, `Unable to unstack`);
  431. }
  432. };
  433. </script>
  434. <section
  435. id="immich-asset-viewer"
  436. class="fixed left-0 top-0 z-[1001] grid h-screen w-screen grid-cols-4 grid-rows-[64px_1fr] overflow-y-hidden bg-black"
  437. bind:this={assetViewerHtmlElement}
  438. >
  439. <div class="z-[1000] col-span-4 col-start-1 row-span-1 row-start-1 transition-transform">
  440. {#if isSlideshowMode}
  441. <!-- SlideShowController -->
  442. <div class="flex">
  443. <div class="m-4 flex gap-2">
  444. <CircleIconButton icon={mdiClose} on:click={handleStopSlideshow} title="Exit Slideshow" />
  445. <CircleIconButton
  446. icon={progressBarStatus === ProgressBarStatus.Paused ? mdiPlay : mdiPause}
  447. on:click={() => (progressBarStatus === ProgressBarStatus.Paused ? progressBar.play() : progressBar.pause())}
  448. title={progressBarStatus === ProgressBarStatus.Paused ? 'Play' : 'Pause'}
  449. />
  450. <CircleIconButton icon={mdiChevronLeft} on:click={navigateAssetBackward} title="Previous" />
  451. <CircleIconButton icon={mdiChevronRight} on:click={navigateAssetForward} title="Next" />
  452. </div>
  453. <ProgressBar
  454. autoplay
  455. bind:this={progressBar}
  456. bind:status={progressBarStatus}
  457. on:done={navigateAssetForward}
  458. duration={5000}
  459. />
  460. </div>
  461. {:else}
  462. <AssetViewerNavBar
  463. {asset}
  464. isMotionPhotoPlaying={shouldPlayMotionPhoto}
  465. showCopyButton={canCopyImagesToClipboard && asset.type === AssetTypeEnum.Image}
  466. showZoomButton={asset.type === AssetTypeEnum.Image}
  467. showMotionPlayButton={!!asset.livePhotoVideoId}
  468. showDownloadButton={shouldShowDownloadButton}
  469. showDetailButton={shouldShowDetailButton}
  470. showSlideshow={!!assetStore}
  471. hasStackChildern={$stackAssetsStore.length > 0}
  472. on:goBack={closeViewer}
  473. on:showDetail={showDetailInfoHandler}
  474. on:download={() => downloadFile(asset)}
  475. on:delete={trashOrDelete}
  476. on:favorite={toggleFavorite}
  477. on:addToAlbum={() => openAlbumPicker(false)}
  478. on:addToSharedAlbum={() => openAlbumPicker(true)}
  479. on:playMotionPhoto={() => (shouldPlayMotionPhoto = true)}
  480. on:stopMotionPhoto={() => (shouldPlayMotionPhoto = false)}
  481. on:toggleArchive={toggleArchive}
  482. on:asProfileImage={() => (isShowProfileImageCrop = true)}
  483. on:runJob={({ detail: job }) => handleRunJob(job)}
  484. on:playSlideShow={handlePlaySlideshow}
  485. on:unstack={handleUnstack}
  486. />
  487. {/if}
  488. </div>
  489. {#if !isSlideshowMode && showNavigation}
  490. <div class="column-span-1 z-[999] col-start-1 row-span-1 row-start-2 mb-[60px] justify-self-start">
  491. <NavigationArea on:click={navigateAssetBackward}><Icon path={mdiChevronLeft} size="36" /></NavigationArea>
  492. </div>
  493. {/if}
  494. <!-- Asset Viewer -->
  495. <div class="relative col-span-4 col-start-1 row-span-full row-start-1">
  496. {#if previewStackedAsset}
  497. {#key previewStackedAsset.id}
  498. {#if previewStackedAsset.type === AssetTypeEnum.Image}
  499. <PhotoViewer asset={previewStackedAsset} on:close={closeViewer} haveFadeTransition={false} />
  500. {:else}
  501. <VideoViewer
  502. assetId={previewStackedAsset.id}
  503. on:close={closeViewer}
  504. on:onVideoEnded={handleVideoEnded}
  505. on:onVideoStarted={handleVideoStarted}
  506. />
  507. {/if}
  508. {/key}
  509. {:else}
  510. {#key asset.id}
  511. {#if !asset.resized}
  512. <div class="flex h-full w-full justify-center">
  513. <div
  514. class="px-auto flex aspect-square h-full items-center justify-center bg-gray-100 dark:bg-immich-dark-gray"
  515. >
  516. <Icon path={mdiImageBrokenVariant} size="25%" />
  517. </div>
  518. </div>
  519. {:else if asset.type === AssetTypeEnum.Image}
  520. {#if shouldPlayMotionPhoto && asset.livePhotoVideoId}
  521. <VideoViewer
  522. assetId={asset.livePhotoVideoId}
  523. on:close={closeViewer}
  524. on:onVideoEnded={() => (shouldPlayMotionPhoto = false)}
  525. />
  526. {:else if asset.exifInfo?.projectionType === ProjectionType.EQUIRECTANGULAR || (asset.originalPath && asset.originalPath
  527. .toLowerCase()
  528. .endsWith('.insp'))}
  529. <PanoramaViewer {asset} />
  530. {:else}
  531. <PhotoViewer {asset} on:close={closeViewer} />
  532. {/if}
  533. {:else}
  534. <VideoViewer
  535. assetId={asset.id}
  536. on:close={closeViewer}
  537. on:onVideoEnded={handleVideoEnded}
  538. on:onVideoStarted={handleVideoStarted}
  539. />
  540. {/if}
  541. {#if isShared}
  542. <div class="z-[9999] absolute bottom-0 right-0 mb-6 mr-6 justify-self-end">
  543. <div
  544. class="w-full h-14 flex p-4 text-white items-center justify-center rounded-full gap-4 bg-immich-dark-bg bg-opacity-60"
  545. >
  546. <button on:click={handleFavorite}>
  547. <div class="items-center justify-center">
  548. <Icon path={isLiked ? mdiHeart : mdiHeartOutline} size={24} />
  549. </div>
  550. </button>
  551. <button on:click={handleOpenActivity}>
  552. <div class="flex gap-2 items-center justify-center">
  553. <Icon path={mdiCommentOutline} class="scale-x-[-1]" size={24} />
  554. {#if numberOfComments}
  555. <div class="text-xl">{numberOfComments}</div>
  556. {:else if !isShowActivity && !$isShowDetail}
  557. <div class="text-lg">Say something</div>
  558. {/if}
  559. </div>
  560. </button>
  561. </div>
  562. </div>
  563. {/if}
  564. {/key}
  565. {/if}
  566. {#if $stackAssetsStore.length > 0 && withStacked}
  567. <div
  568. id="stack-slideshow"
  569. class="z-[1005] flex place-item-center place-content-center absolute bottom-0 w-full col-span-4 col-start-1 mb-1 overflow-x-auto horizontal-scrollbar"
  570. >
  571. <div class="relative whitespace-nowrap transition-all">
  572. {#each $stackAssetsStore as stackedAsset (stackedAsset.id)}
  573. <div
  574. class="{stackedAsset.id == asset.id
  575. ? '-translate-y-[1px]'
  576. : '-translate-y-0'} inline-block px-1 transition-transform"
  577. >
  578. <Thumbnail
  579. class="{stackedAsset.id == asset.id
  580. ? 'bg-transparent border-2 border-white'
  581. : 'bg-gray-700/40'} inline-block hover:bg-transparent"
  582. asset={stackedAsset}
  583. on:click={() => (asset = stackedAsset)}
  584. on:mouse-event={(e) => handleStackedAssetMouseEvent(e, stackedAsset)}
  585. readonly
  586. thumbnailSize={stackedAsset.id == asset.id ? 65 : 60}
  587. showStackedIcon={false}
  588. />
  589. {#if stackedAsset.id == asset.id}
  590. <div class="w-full flex place-items-center place-content-center">
  591. <div class="w-2 h-2 bg-white rounded-full flex mt-[2px]" />
  592. </div>
  593. {/if}
  594. </div>
  595. {/each}
  596. </div>
  597. </div>
  598. {/if}
  599. </div>
  600. <!-- Stack & Stack Controller -->
  601. {#if !isSlideshowMode && showNavigation}
  602. <div class="z-[999] col-span-1 col-start-4 row-span-1 row-start-2 mb-[60px] justify-self-end">
  603. <NavigationArea on:click={navigateAssetForward}><Icon path={mdiChevronRight} size="36" /></NavigationArea>
  604. </div>
  605. {/if}
  606. {#if !isSlideshowMode && $isShowDetail}
  607. <div
  608. transition:fly={{ duration: 150 }}
  609. id="detail-panel"
  610. class="z-[1002] row-start-1 row-span-5 w-[360px] overflow-y-auto bg-immich-bg transition-all dark:border-l dark:border-l-immich-dark-gray dark:bg-immich-dark-bg"
  611. translate="yes"
  612. >
  613. <DetailPanel
  614. {asset}
  615. albums={appearsInAlbums}
  616. on:close={() => ($isShowDetail = false)}
  617. on:close-viewer={handleCloseViewer}
  618. on:description-focus-in={disableKeyDownEvent}
  619. on:description-focus-out={enableKeyDownEvent}
  620. />
  621. </div>
  622. {/if}
  623. {#if isShared && album && isShowActivity && user}
  624. <div
  625. transition:fly={{ duration: 150 }}
  626. id="activity-panel"
  627. class="z-[1002] row-start-1 row-span-5 w-[460px] overflow-y-auto bg-immich-bg transition-all dark:border-l dark:border-l-immich-dark-gray dark:bg-immich-dark-bg pl-4"
  628. translate="yes"
  629. >
  630. <ActivityViewer
  631. {user}
  632. assetType={asset.type}
  633. albumOwnerId={album.ownerId}
  634. albumId={album.id}
  635. assetId={asset.id}
  636. bind:reactions
  637. on:addComment={() => numberOfComments++}
  638. on:deleteComment={() => numberOfComments--}
  639. on:deleteLike={() => (isLiked = null)}
  640. on:close={() => (isShowActivity = false)}
  641. />
  642. </div>
  643. {/if}
  644. {#if isShowAlbumPicker}
  645. <AlbumSelectionModal
  646. shared={addToSharedAlbum}
  647. on:newAlbum={handleAddToNewAlbum}
  648. on:newSharedAlbum={handleAddToNewAlbum}
  649. on:album={handleAddToAlbum}
  650. on:close={() => (isShowAlbumPicker = false)}
  651. />
  652. {/if}
  653. {#if isShowDeleteConfirmation}
  654. <ConfirmDialogue
  655. title="Delete {getAssetType(asset.type)}"
  656. confirmText="Delete"
  657. on:confirm={deleteAsset}
  658. on:cancel={() => (isShowDeleteConfirmation = false)}
  659. >
  660. <svelte:fragment slot="prompt">
  661. <p>
  662. Are you sure you want to delete this {getAssetType(asset.type).toLowerCase()}? This will also remove it from
  663. its album(s).
  664. </p>
  665. <p><b>You cannot undo this action!</b></p>
  666. </svelte:fragment>
  667. </ConfirmDialogue>
  668. {/if}
  669. {#if isShowProfileImageCrop}
  670. <ProfileImageCropper
  671. {asset}
  672. on:close={() => (isShowProfileImageCrop = false)}
  673. on:close-viewer={handleCloseViewer}
  674. />
  675. {/if}
  676. </section>
  677. <style>
  678. #immich-asset-viewer {
  679. contain: layout;
  680. }
  681. .horizontal-scrollbar::-webkit-scrollbar {
  682. width: 8px;
  683. height: 10px;
  684. }
  685. /* Track */
  686. .horizontal-scrollbar::-webkit-scrollbar-track {
  687. background: #000000;
  688. border-radius: 16px;
  689. }
  690. /* Handle */
  691. .horizontal-scrollbar::-webkit-scrollbar-thumb {
  692. background: rgba(159, 159, 159, 0.408);
  693. border-radius: 16px;
  694. }
  695. /* Handle on hover */
  696. .horizontal-scrollbar::-webkit-scrollbar-thumb:hover {
  697. background: #adcbfa;
  698. border-radius: 16px;
  699. }
  700. </style>