[PR #237] [MERGED] viewer: a trackpad's sideways scroll leaves the camera speed alone (old #6256) #289

Closed
opened 2026-11-26 20:17:23 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/237
Author: @ddddddddwp
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism

Base: main ← Head: fix/viewer-horizontal-wheel-speed


📝 Commits (1)

  • c1f343a viewer: a trackpad's sideways scroll leaves the camera speed alone (old #6256)

📊 Changes

2 files changed (+20 additions, -1 deletions)

View changed files

📝 tests/test_viewer_streaming.cjs (+15 -0)
📝 viewer/index.html (+5 -1)

📄 Description

Old issue: #6256 (claim in #14).

What

The free camera's wheel handler took every wheel event:

addEventListener("wheel", e => { speed = clamp(speed * (e.deltaY < 0 ? 1.15 : 1 / 1.15), 1, 3000); }, ...);

A trackpad's two-finger sideways scroll is a deltaX-only event with deltaY == 0, so it hit the
deltaY >= 0 branch and divided the camera speed by 1.15 per event: panning sideways slowed the camera down.

The handler now ignores an event whose horizontal component is larger than its vertical one (and an event with
no deltaY), so a pan leaves the speed alone. A mostly vertical wheel, including a diagonal one, still changes
it by 1.15 per notch.

Test

tests/test_viewer_streaming.cjs already loads the viewer module in a VM and captures its wheel handler; the
Shift/Ctrl camera test now drives it and measures Climb per 0.1 s frame at 40 m/s:

  • a sideways event (deltaX 120, deltaY 0) keeps 4 m, and the other direction too;
  • a diagonal with the horizontal dominant (deltaX 120, deltaY 10) keeps 4 m;
  • one notch up (deltaY -100) gives 4.6 m, and one notch down brings it back to 4 m.

With the old handler the first sideways event takes the speed to 40 / 1.15 = 34.8 m/s, so the test fails with
3.4782608695652173 is not 4.

Run: node --test tests/test_viewer_streaming.cjs - 57/57 pass; node --test tests/test_viewer_studio.cjs -
11/11 pass. Node 22.23 on macOS arm64. No game files, no GPU, nothing online.

AI-assisted.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/237 **Author:** [@ddddddddwp](https://github.com/ddddddddwp) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@ubiquitarianism](https://github.com/ubiquitarianism) **Base:** `main` ← **Head:** `fix/viewer-horizontal-wheel-speed` --- ### 📝 Commits (1) - [`c1f343a`](https://github.com/ubiquitarianism/leonida/commit/c1f343a1ae821807b013903383c5c16526f7ef4e) viewer: a trackpad's sideways scroll leaves the camera speed alone (old #6256) ### 📊 Changes **2 files changed** (+20 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_viewer_streaming.cjs` (+15 -0) 📝 `viewer/index.html` (+5 -1) </details> ### 📄 Description Old issue: #6256 (claim in #14). ## What The free camera's wheel handler took every `wheel` event: ```js addEventListener("wheel", e => { speed = clamp(speed * (e.deltaY < 0 ? 1.15 : 1 / 1.15), 1, 3000); }, ...); ``` A trackpad's two-finger sideways scroll is a `deltaX`-only event with `deltaY == 0`, so it hit the `deltaY >= 0` branch and divided the camera speed by 1.15 per event: panning sideways slowed the camera down. The handler now ignores an event whose horizontal component is larger than its vertical one (and an event with no `deltaY`), so a pan leaves the speed alone. A mostly vertical wheel, including a diagonal one, still changes it by 1.15 per notch. ## Test `tests/test_viewer_streaming.cjs` already loads the viewer module in a VM and captures its `wheel` handler; the Shift/Ctrl camera test now drives it and measures Climb per 0.1 s frame at 40 m/s: - a sideways event (`deltaX 120`, `deltaY 0`) keeps 4 m, and the other direction too; - a diagonal with the horizontal dominant (`deltaX 120`, `deltaY 10`) keeps 4 m; - one notch up (`deltaY -100`) gives 4.6 m, and one notch down brings it back to 4 m. With the old handler the first sideways event takes the speed to 40 / 1.15 = 34.8 m/s, so the test fails with `3.4782608695652173 is not 4`. Run: `node --test tests/test_viewer_streaming.cjs` - 57/57 pass; `node --test tests/test_viewer_studio.cjs` - 11/11 pass. Node 22.23 on macOS arm64. No game files, no GPU, nothing online. AI-assisted. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:17:23 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#289
No description provided.