mirror of
https://github.com/m1k1o/neko.git
synced 2025-06-03 11:22:37 +02:00
fix fast scroll speed on macos. (#85)
This commit is contained in:
parent
ffcca402ef
commit
429fc7eb68
2 changed files with 22 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue