fix: adjust trackpad detection and wheel zoom scaling#14
Open
viazovskyi585 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Chrome/Edge for Windows, ctrl+wheel zooms in but does nothing on zoom-out. The fix is in
coreso both the Vue and React wrappers pick it up.Should be related to #1
Root cause
Two things compounded:
detectTrackpadmisclassified Windows wheel. It returnedtruewheneverdeltaMode === 0(pixel mode). Chromium on Windows reports mouse-wheel events in pixel mode withdeltaY = ±100(or ±120) per notch, so a regular mouse was treated as a trackpad.The zoom math then broke for the zoom-out direction. With
isTrackpad = true,handleWheelskipped its±100 → ±1mouse normalization, leavingdeltaY = 100. Combined with the trackpadzoomSpeed = 0.01.Zoom-in had
scaleFactor = 2and still worked, just over-aggressively.Changes
core/src/helpers.ts-detectTrackpadPixel 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 legacywheelDeltaY / deltaY === -3ratio still applies - momentum-scroll deltas stay small, so the magnitude check keeps them classified as trackpad.core/src/zoompinch.ts-handleWheelDefensive cap on the per-event zoom multiplier:Test plan
Need some help testing coz i don't have any windows/linux laptop.