Skip to content

feat(zoom): add trackpad pinch-to-zoom support#1633

Open
swaroopbutala wants to merge 1 commit intobox:masterfrom
swaroopbutala:pinch_to_zoom
Open

feat(zoom): add trackpad pinch-to-zoom support#1633
swaroopbutala wants to merge 1 commit intobox:masterfrom
swaroopbutala:pinch_to_zoom

Conversation

@swaroopbutala
Copy link
Copy Markdown

On Mac trackpads, pinch gestures emit wheel events with ctrlKey set to true. This change adds a wheelZoomHandler to DocBaseViewer, ImageBaseViewer, and TextBaseViewer that intercepts these events to provide smooth, proportional zoom behavior without triggering native browser zoom.

Summary of changes:

  • DocBaseViewer: Added wheelZoomHandler that adjusts pdfViewer scale proportionally, clamped between MIN_SCALE and MAX_SCALE
  • ImageBaseViewer: Added wheelZoomHandler that adjusts image element width proportionally and emits zoom events
  • TextBaseViewer: Added wheelZoomHandler that adjusts font size proportionally, plus new bindDOMListeners/unbindDOMListeners lifecycle methods and proper cleanup in destroy()
  • All viewers register the wheel listener with { passive: false } to allow preventDefault() and block native browser zoom
  • Added comprehensive unit tests for all three viewers

On Mac trackpads, pinch gestures emit wheel events with ctrlKey set to
true. This change adds a wheelZoomHandler to DocBaseViewer, ImageBaseViewer,
and TextBaseViewer that intercepts these events to provide smooth,
proportional zoom behavior without triggering native browser zoom.

Summary of changes:
- DocBaseViewer: Added wheelZoomHandler that adjusts pdfViewer scale
  proportionally, clamped between MIN_SCALE and MAX_SCALE
- ImageBaseViewer: Added wheelZoomHandler that adjusts image element width
  proportionally and emits zoom events
- TextBaseViewer: Added wheelZoomHandler that adjusts font size
  proportionally, plus new bindDOMListeners/unbindDOMListeners lifecycle
  methods and proper cleanup in destroy()
- All viewers register the wheel listener with { passive: false } to allow
  preventDefault() and block native browser zoom
- Added comprehensive unit tests for all three viewers
@swaroopbutala swaroopbutala requested a review from a team as a code owner April 16, 2026 18:53
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

3 participants