1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 11:24:37 +02:00

fix(web): exiting a slideshow will no longer hide the cursor (#9931)

This commit is contained in:
Snowknight26 2024-06-01 17:55:59 -05:00 committed by GitHub
parent 21718cc343
commit 4e16e2520d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,24 +25,32 @@
let unsubscribeRestart: () => void;
let unsubscribeStop: () => void;
const resetTimer = () => {
clearTimeout(timer);
document.body.style.cursor = '';
showControls = true;
startTimer();
const setCursorStyle = (style: string) => {
document.body.style.cursor = style;
};
const startTimer = () => {
const stopControlsHideTimer = () => {
clearTimeout(timer);
setCursorStyle('');
};
const showControlBar = () => {
showControls = true;
stopControlsHideTimer();
hideControlsAfterDelay();
};
const hideControlsAfterDelay = () => {
timer = setTimeout(() => {
if (!isOverControls) {
showControls = false;
document.body.style.cursor = 'none';
setCursorStyle('none');
}
}, 10_000);
};
onMount(() => {
startTimer();
hideControlsAfterDelay();
unsubscribeRestart = restartProgress.subscribe((value) => {
if (value) {
progressBar.restart(value);
@ -52,6 +60,7 @@
unsubscribeStop = stopProgress.subscribe((value) => {
if (value) {
progressBar.restart(false);
stopControlsHideTimer();
}
});
});
@ -75,15 +84,15 @@
};
</script>
<svelte:window on:mousemove={resetTimer} />
<svelte:window on:mousemove={showControlBar} />
{#if showControls}
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div
class="m-4 flex gap-2"
on:mouseenter={() => (isOverControls = true)}
on:mouseleave={() => (isOverControls = false)}
transition:fly={{ duration: 150 }}
role="navigation"
>
<CircleIconButton buttonSize="50" icon={mdiClose} on:click={onClose} title="Exit Slideshow" />