Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading