Skip to content

Commit 777d27d

Browse files
committed
fix: hide cursor conditions
1 parent e434c9d commit 777d27d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/client/composables/useHideCursorIdle.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Ref } from 'vue'
22
import { useEventListener } from '@vueuse/core'
3-
import { computed } from 'vue'
3+
import { computed, watch } from 'vue'
44
import { hideCursorIdle } from '../state'
55

66
const TIMEOUT = 2000
@@ -19,15 +19,24 @@ export function useHideCursorIdle(
1919

2020
let timer: ReturnType<typeof setTimeout> | null = null
2121

22+
// If disabled, immediately show the cursor
23+
watch(
24+
shouldHide,
25+
(value) => {
26+
if (!value)
27+
show()
28+
},
29+
)
30+
2231
useEventListener(
2332
document.body,
2433
['pointermove', 'pointerdown'],
2534
() => {
2635
show()
27-
if (!shouldHide.value)
28-
return
2936
if (timer)
3037
clearTimeout(timer)
38+
if (!shouldHide.value)
39+
return
3140
timer = setTimeout(hide, TIMEOUT)
3241
},
3342
{ passive: true },

0 commit comments

Comments
 (0)