fix fast scroll speed on macos. (#85)

This commit is contained in:
Miroslav Šedivý 2021-07-17 11:56:26 +02:00 committed by GitHub
parent ffcca402ef
commit 429fc7eb68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -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.

View File

@ -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) {