Skip to content

Support 2-finger touchpad gesture and Ctrl+mouse wheel to zoom - #740

Open
rongjie-alter wants to merge 3 commits into
jiangtian616:masterfrom
rongjie-alter:zoom
Open

rongjie-alter wants to merge 3 commits into
jiangtian616:masterfrom
rongjie-alter:zoom

Conversation

@rongjie-alter

@rongjie-alter rongjie-alter commented Feb 21, 2026

Copy link
Copy Markdown

Feature

2-finger touchpad gesture zoom

  • Able to freely zoom in/out with 2-finger touchpad gesture
  • Works in all Reading Direction
    • Continuous mode has the best experience: able to zoom in to all corners of the page
    • In other Reading Direction, sometime unable to zoom to corner area of a page (because reader will just move to the next/prev page after pulling to a certain extent)

Ctrl+mouse wheel zoom

  • Seems to only works in "LTR/RTL + Single Page/Double Columns" Reading Direction mode
  • Ctrl + Mouse wheel up to zoom in, Ctrl + Mouse wheel down to zoom out

Testing

Disclaimer

  • Most of the code are written by Antigravity (Gemini), I practically has no experience with Flutter

@rongjie-alter

Copy link
Copy Markdown
Author

Summary of Changes

  1. Enhanced
    EHWheelListener: Added support for PointerPanZoomUpdateEvent, which is the modern Flutter way to handle trackpad gestures like pinch-to-zoom on Windows and other desktop platforms.
  2. Updated
    BaseLayoutLogic:
    • Implemented handlers for trackpad pinch gestures (
      onPointerPanZoomUpdate).
    • Added support for zooming with the mouse wheel while holding the Ctrl key.
    • Created a unified
      handleScale method to smoothly update the image scale.
  3. Unified Zooming across Layouts:
    • All reading layouts (Vertical List, Horizontal List, Single Page, and Double Column) now use a shared PhotoViewController to handle global viewport zooming.
    • Wrapped the gallery layouts in a zoomable container that responds to both trackpad and mouse wheel gestures.
  4. Aesthetic Refinements: Ensured that the scale state resets gracefully when double-tapping or switching modes, maintaining a premium user experience.
  5. Defined Global Constant: Added static const double readPageMaxScale \= 3.0; to
    UIConfig in
    lib/src/config/ui_config.dart. This provides a single source of truth for the maximum image scale across the entire reading experience.
  6. Updated Logic Class: Modified
    BaseLayoutLogic to import
    UIConfig and use the new constant in trackpad and mouse wheel zoom calculations.
  7. Updated UI Layouts: Replaced all hardcoded 2.5 values with UIConfig.readPageMaxScale in the following layout files:
    • VerticalListLayout
    • HorizontalListLayout
    • HorizontalPageLayout
    • HorizontalDoubleColumnLayout

These changes allow desktop users to freely zoom in and out of images using standard trackpad gestures, making the reading experience much more intuitive and "native" to the desktop environment.

@jiangtian616 jiangtian616 self-assigned this Feb 23, 2026
@jiangtian616

Copy link
Copy Markdown
Owner

It seems that the two newly added gestures do not recognize the zoom focal point. Instead, they simply zoom in with the center of the screen as the focal point. This behavior is inconsistent with the existing double-tap zoom and tap-and-drag zoom gestures.
image

After testing, the mouse wheel zoom is not compatible with the current zoom gestures:

After zooming with the mouse wheel, the scale cannot be reset via double-tap.

After zooming via tap-and-drag, the mouse wheel zoom no longer works properly.

Ensuring compatibility among the different zoom gestures may require rewriting the underlying photo_view component, as it appears difficult to achieve this solely at the application layer.

@rongjie-alter

rongjie-alter commented Feb 27, 2026

Copy link
Copy Markdown
Author

It seems that the two newly added gestures do not recognize the zoom focal point. Instead, they simply zoom in with the center of the screen as the focal point

Oh, no wonder when I tested it myself, I felt that the zooming is a bit awkward sometime but cannot describe what is wrong. The problem isn't big enough to affect my usage personally.

I am not very sure how to fix this more properly in photo_view component

The screenshots in https://github.com/bluefireteam/photo_view?tab=readme-ov-file#more-screenshots does seem to support 2-finger zoom gesture, so I still don't understand why it doesn't already work on JHentai

I guess we won't be merging this PR, though it is enough for my own usage so I will just use my own built binary (I only care about 2-finger zoom gesture on desktop)

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.

2 participants