Skip to content

Commit 308f74d

Browse files
authored
fix: clear idle cursor timeout when disabling the option or changing mode (#2147)
1 parent 9e49735 commit 308f74d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Diff for: packages/client/composables/useHideCursorIdle.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,30 @@ export function useHideCursorIdle(
1717
document.body.style.cursor = ''
1818
}
1919

20-
// If disabled, immediately show the cursor
20+
let timer: ReturnType<typeof setTimeout> | null = null
21+
22+
// If disabled, immediately show the cursor and stop the timer
2123
watch(
2224
shouldHide,
2325
(value) => {
24-
if (!value)
26+
if (!value) {
2527
show()
28+
if (timer) {
29+
clearTimeout(timer)
30+
}
31+
timer = null
32+
}
2633
},
2734
)
28-
onScopeDispose(show)
2935

30-
let timer: ReturnType<typeof setTimeout> | null = null
36+
onScopeDispose(() => {
37+
show()
38+
if (timer) {
39+
clearTimeout(timer)
40+
}
41+
timer = null
42+
})
43+
3144
useEventListener(
3245
document.body,
3346
['pointermove', 'pointerdown'],

0 commit comments

Comments
 (0)