Skip to content

Commit

Permalink
fix(web): exiting a slideshow will no longer hide the cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowknight26 committed Jun 1, 2024
1 parent 21718cc commit b4c153b
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions web/src/lib/components/asset-viewer/slideshow-bar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,32 @@
let unsubscribeRestart: () => void;
let unsubscribeStop: () => void;
const resetTimer = () => {
const setCursorStyle = (style: string) => {
document.body.style.cursor = style;
};
const stopControlsHideTimer = () => {
clearTimeout(timer);
document.body.style.cursor = '';
setCursorStyle('');
};
const showControlBar = () => {
showControls = true;
startTimer();
stopControlsHideTimer();
hideControlsAfterDelay();
};
const startTimer = () => {
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);
Expand All @@ -52,6 +60,7 @@
unsubscribeStop = stopProgress.subscribe((value) => {
if (value) {
progressBar.restart(false);
stopControlsHideTimer();
}
});
});
Expand All @@ -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" />

Expand Down

0 comments on commit b4c153b

Please sign in to comment.