From 429fc7eb689ae9b58ff0c44c1bb4d8434dca3d7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 17 Jul 2021 11:56:26 +0200 Subject: [PATCH] fix fast scroll speed on macos. (#85) --- README.md | 1 + client/src/components/video.vue | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 203103ce..a701a3c4 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ For n.eko room management software visit https://github.com/m1k1o/neko-rooms. - While IP address fetching is now proxy ignored. - Start unmuted on reconnects. - Switched to latest firefox version instead of esr. +- Fixed very fast scroll speed on MacOS. ### Roadmap & TODOs - Catch errors from gst pipeline, tell user if broadcast failed. diff --git a/client/src/components/video.vue b/client/src/components/video.vue index 593e6756..546e66d9 100644 --- a/client/src/components/video.vue +++ b/client/src/components/video.vue @@ -193,6 +193,8 @@ // @ts-ignore import GuacamoleKeyboard from '~/utils/guacamole-keyboard.ts' + const WHEEL_LINE_HEIGHT = 19 + @Component({ name: 'neko-video', components: { @@ -594,6 +596,7 @@ }) } + wheelThrottle = false onWheel(e: WheelEvent) { if (!this.hosting || this.locked) { return @@ -603,6 +606,16 @@ let x = e.deltaX let y = e.deltaY + // Pixel units unless it's non-zero. + // Note that if deltamode is line or page won't matter since we aren't + // sending the mouse wheel delta to the server anyway. + // The difference between pixel and line can be important however since + // we have a threshold that can be smaller than the line height. + if (e.deltaMode !== 0) { + x *= WHEEL_LINE_HEIGHT + y *= WHEEL_LINE_HEIGHT + } + if (this.scroll_invert) { x = x * -1 y = y * -1 @@ -611,7 +624,14 @@ x = Math.min(Math.max(x, -this.scroll), this.scroll) y = Math.min(Math.max(y, -this.scroll), this.scroll) - this.$client.sendData('wheel', { x, y }) + if (!this.wheelThrottle) { + this.wheelThrottle = true + this.$client.sendData('wheel', { x, y }) + + window.setTimeout(() => { + this.wheelThrottle = false + }, 100) + } } onMouseDown(e: MouseEvent) {