Skip to content

Commit 2a0b7fa

Browse files
committed
feat: update neko base to v1.5.0, fix scroll defaults and Vue 2 reactivity
- Bump neko base image to 3.0.8-v1.5.0 (XI2.1 smooth scrolling support) - Default scroll_invert to false (works with --disable-features=ScrollLatching) - Add useDefineForClassFields: false to tsconfig for Vue 2 compatibility - Use document-level wheel listener with capture: true for reliable interception - Send scroll deltas directly without rAF batching or accumulation - Extract magic numbers into named constants (SCROLL_SENSITIVITY_BASE, INT16_MAX) Made-with: Cursor
1 parent 11c1ba1 commit 2a0b7fa

4 files changed

Lines changed: 13 additions & 32 deletions

File tree

images/chromium-headful/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ RUN --mount=type=cache,target=/tmp/cache/ffmpeg,sharing=locked,id=$CACHEIDPREFIX
146146
rm -rf /tmp/ffmpeg*
147147
EOT
148148

149-
FROM ghcr.io/kernel/neko/base:3.0.8-v1.4.0 AS neko
150-
# TODO: update to xi2-scroll tag once kernel/neko#12 is merged and tagged
149+
FROM ghcr.io/kernel/neko/base:3.0.8-v1.5.0 AS neko
151150
FROM node:22-bullseye-slim AS node-22
152151
FROM docker.io/ubuntu:22.04
153152

images/chromium-headful/client/src/components/video.vue

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@
230230
import GuacamoleKeyboard from '~/utils/guacamole-keyboard.ts'
231231
232232
const WHEEL_LINE_HEIGHT = 19
233+
const SCROLL_SENSITIVITY_BASE = 10
234+
const INT16_MAX = 32767
233235
234236
@Component({
235237
name: 'neko-video',
@@ -534,7 +536,7 @@
534536
if (this.locked) return
535537
this.onWheel(e)
536538
}
537-
this._overlay.addEventListener('wheel', this._wheelHandler, { passive: false })
539+
document.addEventListener('wheel', this._wheelHandler, { passive: false, capture: true })
538540
539541
/* Initialize Guacamole Keyboard */
540542
this.keyboard.onkeydown = (key: number) => {
@@ -562,13 +564,9 @@
562564
563565
beforeDestroy() {
564566
if (this._wheelHandler) {
565-
this._overlay.removeEventListener('wheel', this._wheelHandler)
567+
document.removeEventListener('wheel', this._wheelHandler, { capture: true })
566568
this._wheelHandler = null
567569
}
568-
if (this._scrollRaf !== null) {
569-
cancelAnimationFrame(this._scrollRaf)
570-
this._scrollRaf = null
571-
}
572570
this.observer.disconnect()
573571
this.$accessor.video.setPlayable(false)
574572
/* Guacamole Keyboard does not provide destroy functions */
@@ -725,11 +723,6 @@
725723
})
726724
}
727725
728-
private _scrollAccX = 0
729-
private _scrollAccY = 0
730-
private _scrollCtrl = false
731-
private _scrollRaf: number | null = null
732-
733726
onWheel(e: WheelEvent) {
734727
this.sendMousePos(e)
735728
@@ -746,24 +739,12 @@
746739
y *= -1
747740
}
748741
749-
const sensitivity = this.scroll / 10
750-
this._scrollAccX += x * sensitivity
751-
this._scrollAccY += y * sensitivity
752-
this._scrollCtrl = e.ctrlKey || e.metaKey
753-
754-
if (this._scrollRaf === null) {
755-
this._scrollRaf = requestAnimationFrame(() => {
756-
this._scrollRaf = null
757-
const dx = Math.max(-32767, Math.min(32767, Math.round(this._scrollAccX)))
758-
const dy = Math.max(-32767, Math.min(32767, Math.round(this._scrollAccY)))
759-
const ctrl = this._scrollCtrl
760-
this._scrollAccX -= dx
761-
this._scrollAccY -= dy
762-
this._scrollCtrl = false
763-
if (dx !== 0 || dy !== 0) {
764-
this.$client.sendData('wheel', { x: dx, y: dy, controlKey: ctrl })
765-
}
766-
})
742+
const sensitivity = this.scroll / SCROLL_SENSITIVITY_BASE
743+
const dx = Math.max(-INT16_MAX, Math.min(INT16_MAX, Math.round(x * sensitivity)))
744+
const dy = Math.max(-INT16_MAX, Math.min(INT16_MAX, Math.round(y * sensitivity)))
745+
746+
if (dx !== 0 || dy !== 0) {
747+
this.$client.sendData('wheel', { x: dx, y: dy, controlKey: e.ctrlKey || e.metaKey })
767748
}
768749
}
769750

images/chromium-headful/client/src/store/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface KeyboardLayouts {
1212
export const state = () => {
1313
return {
1414
scroll: get<number>('scroll', 10),
15-
scroll_invert: get<boolean>('scroll_invert', true),
15+
scroll_invert: get<boolean>('scroll_invert', false),
1616
autoplay: get<boolean>('autoplay', true),
1717
ignore_emotes: get<boolean>('ignore_emotes', false),
1818
chat_sound: get<boolean>('chat_sound', true),

images/chromium-headful/client/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"importHelpers": true,
88
"moduleResolution": "node",
99
"experimentalDecorators": true,
10+
"useDefineForClassFields": false,
1011
"esModuleInterop": true,
1112
"allowSyntheticDefaultImports": true,
1213
"sourceMap": true,

0 commit comments

Comments
 (0)