Skip to content

Commit 9cd885f

Browse files
committed
Improved mouse wheel event handling and debounce logic in the home page controller
1 parent 84bf625 commit 9cd885f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

frontend/src/views/HomeView/index.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { ref, watch, useTemplateRef, h } from 'vue'
33
import { useI18n } from 'vue-i18n'
44
5-
import { APP_TITLE, message } from '@/utils'
5+
import { APP_TITLE, debounce, message } from '@/utils'
66
import { useAppSettingsStore, useProfilesStore, useKernelApiStore, useEnvStore } from '@/stores'
77
88
import { useModal } from '@/components/Modal'
@@ -102,11 +102,24 @@ const handleShowKernelLogs = () => {
102102
.open()
103103
}
104104
105+
let scrollEventCount = 0
106+
const resetScrollEventCount = debounce(() => (scrollEventCount = 0), 100)
107+
105108
const onMouseWheel = (e: WheelEvent) => {
106109
if (!appSettingsStore.app.kernel.running) return
107-
const isDown = e.deltaY > 0
108110
109-
showController.value = isDown || controllerRef.value?.scrollTop !== 0
111+
const currentScrollTop = controllerRef.value?.scrollTop ?? 0
112+
const isScrollingDown = e.deltaY > 0
113+
114+
if (isScrollingDown || currentScrollTop === 0) {
115+
scrollEventCount += 1
116+
}
117+
118+
if (scrollEventCount >= 5) {
119+
showController.value = isScrollingDown || currentScrollTop !== 0
120+
}
121+
122+
resetScrollEventCount()
110123
}
111124
112125
const onTunSwitchChange = async (enable: boolean) => {

0 commit comments

Comments
 (0)