From f091e400f4b30fe5b67452f31ee027437ff131a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Wed, 18 Oct 2023 12:16:03 -0700 Subject: [PATCH] App: Hide mouse if not moving for 5 seconds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/App.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/App.vue b/src/App.vue index a176b944d..eb2d3e328 100644 --- a/src/App.vue +++ b/src/App.vue @@ -166,6 +166,21 @@ const showMissionOptionsDialog = ref(false) // Clock const timeNow = useTimestamp({ interval: 1000 }) + +// Control showing mouse +let hideMouseTimeoutId: ReturnType + +const hideMouse = (): void => { + document.body.classList.add('hide-cursor') +} + +const resetHideMouseTimeout = (): void => { + clearTimeout(hideMouseTimeoutId) + document.body.classList.remove('hide-cursor') + hideMouseTimeoutId = setTimeout(hideMouse, 5000) +} + +document.addEventListener('mousemove', resetHideMouseTimeout)