diff --git a/web/src/lib/components/asset-viewer/photo-viewer.svelte b/web/src/lib/components/asset-viewer/photo-viewer.svelte index 14bbb6b1fa..6285a63006 100644 --- a/web/src/lib/components/asset-viewer/photo-viewer.svelte +++ b/web/src/lib/components/asset-viewer/photo-viewer.svelte @@ -14,6 +14,9 @@ import LoadingSpinner from '../shared-components/loading-spinner.svelte'; import { NotificationType, notificationController } from '../shared-components/notification/notification'; import { getAltText } from '$lib/utils/thumbnail-util'; + import { slideshowLookCssMapping, SlideshowState, slideshowStore } from '$lib/stores/slideshow.store'; + + const { slideshowState, slideshowLook } = slideshowStore; export let asset: AssetResponseDto; export let preloadAssets: AssetResponseDto[] | null = null; @@ -158,7 +161,9 @@ transition:fade={{ duration: haveFadeTransition ? 150 : 0 }} src={assetData} alt={getAltText(asset)} - class="h-full w-full object-contain" + class="h-full w-full {$slideshowState === SlideshowState.None + ? 'object-contain' + : slideshowLookCssMapping[$slideshowLook]}" draggable="false" /> {#each getBoundingBox($boundingBoxesArray, $photoZoomState, $photoViewer) as boundingbox} diff --git a/web/src/lib/components/slideshow-settings.svelte b/web/src/lib/components/slideshow-settings.svelte index 7a0da7b836..d0ac5eab93 100644 --- a/web/src/lib/components/slideshow-settings.svelte +++ b/web/src/lib/components/slideshow-settings.svelte @@ -4,27 +4,34 @@ SettingInputFieldType, } from '$lib/components/shared-components/settings/setting-input-field.svelte'; import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte'; - import { mdiArrowDownThin, mdiArrowUpThin, mdiShuffle } from '@mdi/js'; - import { SlideshowNavigation, slideshowStore } from '../stores/slideshow.store'; + import { mdiArrowDownThin, mdiArrowUpThin, mdiFitToPageOutline, mdiFitToScreenOutline, mdiShuffle } from '@mdi/js'; + import { SlideshowLook, SlideshowNavigation, slideshowStore } from '../stores/slideshow.store'; import Button from './elements/buttons/button.svelte'; import type { RenderedOption } from './elements/dropdown.svelte'; import SettingDropdown from './shared-components/settings/setting-dropdown.svelte'; - const { slideshowDelay, showProgressBar, slideshowNavigation } = slideshowStore; + const { slideshowDelay, showProgressBar, slideshowNavigation, slideshowLook } = slideshowStore; export let onClose = () => {}; - const options: Record = { + const navigationOptions: Record = { [SlideshowNavigation.Shuffle]: { icon: mdiShuffle, title: 'Shuffle' }, [SlideshowNavigation.AscendingOrder]: { icon: mdiArrowUpThin, title: 'Backward' }, [SlideshowNavigation.DescendingOrder]: { icon: mdiArrowDownThin, title: 'Forward' }, }; - const handleToggle = (selectedOption: RenderedOption) => { + const lookOptions: Record = { + [SlideshowLook.Contain]: { icon: mdiFitToScreenOutline, title: 'Contain' }, + [SlideshowLook.Cover]: { icon: mdiFitToPageOutline, title: 'Cover' }, + }; + + const handleToggle = ( + record: RenderedOption, + options: Record, + ): undefined | Type => { for (const [key, option] of Object.entries(options)) { - if (option === selectedOption) { - $slideshowNavigation = key as SlideshowNavigation; - break; + if (option === record) { + return key as Type; } } }; @@ -34,9 +41,19 @@
handleToggle(option)} + options={Object.values(navigationOptions)} + selectedOption={navigationOptions[$slideshowNavigation]} + onToggle={(option) => { + $slideshowNavigation = handleToggle(option, navigationOptions) || $slideshowNavigation; + }} + /> + { + $slideshowLook = handleToggle(option, lookOptions) || $slideshowLook; + }} /> = { + [SlideshowLook.Contain]: 'object-contain', + [SlideshowLook.Cover]: 'object-cover', +}; + function createSlideshowStore() { const restartState = writable(false); const stopState = writable(false); @@ -21,6 +31,7 @@ function createSlideshowStore() { 'slideshow-navigation', SlideshowNavigation.DescendingOrder, ); + const slideshowLook = persisted('slideshow-look', SlideshowLook.Contain); const slideshowState = writable(SlideshowState.None); const showProgressBar = persisted('slideshow-show-progressbar', true); @@ -50,6 +61,7 @@ function createSlideshowStore() { }, }, slideshowNavigation, + slideshowLook, slideshowState, slideshowDelay, showProgressBar,