From dfbdd890863933affc677eafa566d460e19dac39 Mon Sep 17 00:00:00 2001 From: martabal <74269598+martabal@users.noreply.github.com> Date: Sun, 17 Mar 2024 23:17:35 +0100 Subject: [PATCH 1/7] feat: improvements to slideshow --- .../asset-viewer/asset-viewer.svelte | 12 ++++ .../asset-viewer/slideshow-bar.svelte | 66 +++++++++++++++---- .../asset-viewer/video-viewer.svelte | 4 +- 3 files changed, 68 insertions(+), 14 deletions(-) diff --git a/web/src/lib/components/asset-viewer/asset-viewer.svelte b/web/src/lib/components/asset-viewer/asset-viewer.svelte index f9d2f787bb64f..cd11db5e2e110 100644 --- a/web/src/lib/components/asset-viewer/asset-viewer.svelte +++ b/web/src/lib/components/asset-viewer/asset-viewer.svelte @@ -97,6 +97,7 @@ let isShowActivity = false; let isLiked: ActivityResponseDto | null = null; let numberOfComments: number; + let isFullScreen = false; $: { if (asset.stackCount && asset.stack) { @@ -188,7 +189,12 @@ } } + const handleFullScreenChange = () => { + isFullScreen = document.fullscreenElement !== null; + }; + onMount(async () => { + document.addEventListener('fullscreenchange', handleFullScreenChange); slideshowStateUnsubscribe = slideshowState.subscribe((value) => { if (value === SlideshowState.PlaySlideshow) { slideshowHistory.reset(); @@ -226,6 +232,7 @@ }); onDestroy(() => { + document.removeEventListener('fullscreenchange', handleFullScreenChange); if (slideshowStateUnsubscribe) { slideshowStateUnsubscribe(); } @@ -562,6 +569,8 @@ {#if $slideshowState != SlideshowState.None}
assetViewerHtmlElement.requestFullscreen()} onPrevious={() => navigateAsset('previous')} onNext={() => navigateAsset('next')} onClose={() => ($slideshowState = SlideshowState.StopSlideshow)} @@ -575,6 +584,7 @@ {:else} (shouldPlayMotionPhoto = false)} @@ -608,6 +619,7 @@ {/if} {:else} {}; export let onPrevious = () => {}; export let onClose = () => {}; + export let onSetToFullScreen = () => {}; const { restartProgress, stopProgress, slideshowDelay, showProgressBar, slideshowNavigation } = slideshowStore; let progressBarStatus: ProgressBarStatus; let progressBar: ProgressBar; let showSettings = false; + let showControls = true; + let timer: NodeJS.Timeout; + let isOverControls = false; let unsubscribeRestart: () => void; let unsubscribeStop: () => void; + const resetTimer = () => { + clearTimeout(timer); + document.body.style.cursor = ''; + showControls = true; + startTimer(); + }; + + const startTimer = () => { + timer = setTimeout(() => { + if (!isOverControls) { + showControls = false; + document.body.style.cursor = 'none'; + } + }, 10_000); + }; + onMount(() => { + startTimer(); unsubscribeRestart = restartProgress.subscribe((value) => { if (value) { progressBar.restart(value); @@ -52,19 +75,36 @@ }; -
- - (progressBarStatus === ProgressBarStatus.Paused ? progressBar.play() : progressBar.pause())} - title={progressBarStatus === ProgressBarStatus.Paused ? 'Play' : 'Pause'} - /> - - - (showSettings = !showSettings)} title="Next" /> -
+ +{#if showControls} + +
(isOverControls = true)} + on:mouseleave={() => (isOverControls = false)} + transition:fly={{ duration: 150 }} + > + + (progressBarStatus === ProgressBarStatus.Paused ? progressBar.play() : progressBar.pause())} + title={progressBarStatus === ProgressBarStatus.Paused ? 'Play' : 'Pause'} + /> + + + (showSettings = !showSettings)} title="Next" /> + {#if !isFullScreen} + + {/if} +
+{/if} {#if showSettings} (showSettings = false)} /> {/if} diff --git a/web/src/lib/components/asset-viewer/video-viewer.svelte b/web/src/lib/components/asset-viewer/video-viewer.svelte index f5ff5f0fc2ac4..328a0a5f5d26a 100644 --- a/web/src/lib/components/asset-viewer/video-viewer.svelte +++ b/web/src/lib/components/asset-viewer/video-viewer.svelte @@ -8,8 +8,10 @@ import LoadingSpinner from '../shared-components/loading-spinner.svelte'; export let assetId: string; + export let controls: boolean; let isVideoLoading = true; + const dispatch = createEventDispatcher<{ onVideoEnded: void; onVideoStarted: void }>(); const handleCanPlay = async (event: Event) => { @@ -31,7 +33,7 @@