Conversation
SfPdfViewer already scrolls the document on a mouse wheel PointerScrollEvent through _handlePointerSignal. The InteractiveViewer behind the pages scales on the very same event, so the wheel zooms instead of scrolling. Scaling was disabled for that reason on desktop only (_isScaleEnabled was initialised to !kIsDesktop and toggled from touch pointers), which leaves every touch platform that can host a precise pointer broken: iPadOS or Android with a mouse zooms in on wheel up and out on wheel down, and only scrolls once the zoom is clamped. Gate scaling on the pointer kind instead of the platform: scaling is enabled while a touch pointer interacts with the viewer and disabled otherwise, on every platform. Pinch-to-zoom is unaffected, and the wheel now only scrolls.
|
Hi @Ortes , Thank you for sharing your proposal and providing the patch to an issue where mouse wheel zooms instead of scrolling on iPadOS/Android with a physical mouse. Please note that, although the Flutter PDF library source code is publicly available on GitHub for transparency, we do not accept direct contributions to the repository. This policy ensures consistency and quality across all releases. Nevertheless, your feedback and suggestions are highly valued, and we encourage you to continue sharing ideas through our official support channels. Regards, |
Fixes #2558.
Problem
On a touch platform driving a precise pointer — iPadOS or Android with a physical mouse — the mouse wheel zooms
SfPdfViewerinstead of scrolling it.SfPdfVieweralready scrolls the document on a wheelPointerScrollEvent, through its rootListener→_handlePointerSignal→PdfScrollableState.receivedPointerSignal. TheInteractiveViewerbehind the pages consumes the very same event as a scale gesture (InteractiveViewer._receivedPointerSignalscales for anything that is not a trackpad), and it does not go through thePointerSignalResolver, so both run on every tick and the zoom dominates.Scaling was disabled for that reason, but only on desktop:
_isScaleEnabledwas initialised to!kIsDesktop,kIsDesktop,scaleEnabled:was forced totruewhenever!kIsDesktop.That leaves every touch platform permanently scale-enabled, including while the active pointer is a mouse.
Fix
Gate scaling on the pointer kind rather than on the platform.
_updateScaleEnabledenables scaling while a touch pointer interacts with the viewer and disables it otherwise, on every platform, and thekIsDesktopspecial-casing aroundscaleEnabledis dropped.Pinch-to-zoom is unchanged: the flag is armed on touch down, well before a scale gesture can win the arena. The wheel is now left entirely to
_handlePointerSignal.Desktop behaviour is unchanged —
_isScaleEnabledwas alreadyfalsethere and armed by touch pointers.Test plan
I have tested this on my own setup — an iPad with a physical mouse — and it fixes the reported problem: the wheel scrolls the document instead of zooming it. I have not tested it anywhere else, so the points below are what I believe a reviewer should check rather than results I can vouch for:
PdfPageLayoutMode.continuousandsingle.