Skip to content

fix: adjust trackpad detection and wheel zoom scaling#14

Open
viazovskyi585 wants to merge 1 commit into
ElyaConrad:mainfrom
viazovskyi585:fix/wheel-zoom
Open

fix: adjust trackpad detection and wheel zoom scaling#14
viazovskyi585 wants to merge 1 commit into
ElyaConrad:mainfrom
viazovskyi585:fix/wheel-zoom

Conversation

@viazovskyi585

@viazovskyi585 viazovskyi585 commented May 26, 2026

Copy link
Copy Markdown

Summary

On Chrome/Edge for Windows, ctrl+wheel zooms in but does nothing on zoom-out. The fix is in core so both the Vue and React wrappers pick it up.

Should be related to #1

Root cause

Two things compounded:

  1. detectTrackpad misclassified Windows wheel. It returned true whenever deltaMode === 0 (pixel mode). Chromium on Windows reports mouse-wheel events in pixel mode with deltaY = ±100 (or ±120) per notch, so a regular mouse was treated as a trackpad.

  2. The zoom math then broke for the zoom-out direction. With isTrackpad = true, handleWheel skipped its ±100 → ±1 mouse normalization, leaving deltaY = 100. Combined with the trackpad zoomSpeed = 0.01.

Zoom-in had scaleFactor = 2 and still worked, just over-aggressively.

Changes

  • core/src/helpers.ts - detectTrackpad Pixel mode alone isn't enough on Windows. Added a magnitude check: trackpads send small deltas (usually under ~30), mouse wheels send chunks of ~100+ per notch. A 50px threshold sits comfortably in between. Line/page mode remains an unconditional mouse signal. The previous comment about avoiding the legacy wheelDeltaY / deltaY === -3 ratio still applies - momentum-scroll deltas stay small, so the magnitude check keeps them classified as trackpad.

  • core/src/zoompinch.ts - handleWheel Defensive cap on the per-event zoom multiplier:

const cappedDelta = clamp(-deltaY * zoomSpeed, -0.5, 0.5);
const scaleFactor = 1 + cappedDelta;

Test plan

  • Windows + mouse wheel: ctrl+wheel zooms both in and out
  • macOS trackpad: pinch / two-finger ctrl-scroll still zooms smoothly, no jumps during momentum
  • macOS mouse wheel: still zooms
  • Windows trackpad (precision touchpad): still zooms
  • Pan is unchanged on all of the above

Need some help testing coz i don't have any windows/linux laptop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant