Skip to content

fix(editor): wheel scrolling and zoom in Firefox, Shift+wheel and small zoom steps - #402

Merged
AndyScherzinger merged 2 commits into
mainfrom
fix/firefox-wheel
Oct 19, 2026
Merged

AndyScherzinger merged 2 commits into
mainfrom
fix/firefox-wheel

Conversation

@AndyScherzinger

@AndyScherzinger AndyScherzinger commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Fixes #93

In Firefox the mouse wheel did nothing on the mind map canvas: scrolling didn't move the canvas, vertically or horizontally, and Ctrl+wheel didn't zoom. Both work in Chrome. In every browser, Shift+wheel didn't scroll horizontally, and touchpad pinches and small wheel steps didn't zoom.

The vendored KityMinder pans on the non-standard mousewheel event and zooms on it when Ctrl or Cmd is held:

  • Firefox: it never fires mousewheel, and kity doesn't even listen for it there. kity only attaches a DOM listener when the element has an on<type> property ("onmousewheel" in node), which Firefox elements don't have. That also rules out KityMinder's own DOMMouseScroll fallback, so Firefox got no wheel handling at all.
  • Shift: the pan handler ignores the event while Shift is held.
  • Zoom: it only zooms when a single event reports more than 100. A mouse notch in Chrome reports 120, but touchpad pinches and the small pixel steps of macOS never get there.

src/viewer.js, the editor iframe's script, now handles the wheel before the editor does. The vendored files are unchanged.

  • Firefox: elements get an onmousewheel property, so kity binds its listener, and every standard wheel event is re-dispatched as mousewheel with the deltas Chrome reports: 120 per notch of three lines, and 1.2 per pixel.
  • Shift+wheel, all browsers: re-dispatched without Shift and with the delta moved to the horizontal axis, so it scrolls the canvas sideways.
  • Ctrl/Cmd+wheel, all browsers: re-dispatched with at least 120, keeping its direction. The editor waits for 100 ms of quiet before it zooms, so a pinch or a fast series of steps still zooms once per gesture.

In Chrome the native mousewheel passes through untouched in all other cases. When the editor handles an event, the original is cancelled, so the page itself doesn't scroll or zoom too.

Tested on Nextcloud 32, 35 and 36, in Chromium and Firefox, by reading the editor's canvas position and zoom. The results are the same in both browsers and on all three versions:

Input Result
Wheel down / right Canvas scrolls 48 px vertically / horizontally (Firefox before: nothing)
Shift+wheel Canvas scrolls 48 px horizontally (before: nothing in either browser)
Ctrl+wheel, one notch Zoom 100 → 120 → 100 % (Firefox before: nothing)
Ctrl+wheel, 5 px step Zoom 100 → 120 → 100 % (before: nothing)
Cmd+wheel, as on macOS Zoom 100 → 120 %
12 small Ctrl steps in a row, like a pinch One zoom step (120 → 100 %)
One mouse notch in Firefox line mode (simulated) 48 px, same as Chrome

macOS itself wasn't available for testing; the Cmd and small-step cases cover what macOS sends. Lint, Vitest and the build pass. Backport: #403.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

The editor pans on the non-standard mousewheel event and zooms on it with
Ctrl, but kity only listens for an event that elements have an on<type>
property for, and Firefox has neither onmousewheel nor fires mousewheel.
So wheel scrolling and Ctrl+wheel zoom did nothing in Firefox. Where
mousewheel is missing, give elements the property and re-dispatch each
wheel event as mousewheel with the deltas Chrome reports.

Fixes #93

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Oct 19, 2026
@AndyScherzinger AndyScherzinger added the enhancement New feature or request label Oct 19, 2026
@AndyScherzinger AndyScherzinger added this to the v0.2.0 milestone Oct 19, 2026
…l steps

The editor ignored the wheel while Shift was held, and zoomed with Ctrl or
Cmd only once a single event reported more than 100, which touchpad
pinches and the small pixel steps of macOS never do. Re-dispatch the
wheel as mousewheel in Chrome too where needed: with Shift as horizontal
scrolling, and with Ctrl or Cmd with at least 120. The editor still zooms
once per gesture, as it waits for 100 ms of quiet.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger AndyScherzinger changed the title fix(editor): scroll and zoom the mind map with the wheel in Firefox fix(editor): wheel scrolling and zoom in Firefox, Shift+wheel and small zoom steps Oct 19, 2026
@AndyScherzinger
AndyScherzinger merged commit f9d2e66 into main Oct 19, 2026
8 checks passed
@AndyScherzinger
AndyScherzinger deleted the fix/firefox-wheel branch October 19, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted This PR contains AI-assisted commits enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zoom using mouse wheel

2 participants