Skip to content

fix(zoom): bug fixes for pinch to zoom images#1660

Draft
kduncanhsu wants to merge 2 commits into
box:masterfrom
kduncanhsu:kduncanhsu/pinch-to-zoom-images-fixes
Draft

fix(zoom): bug fixes for pinch to zoom images#1660
kduncanhsu wants to merge 2 commits into
box:masterfrom
kduncanhsu:kduncanhsu/pinch-to-zoom-images-fixes

Conversation

@kduncanhsu

Copy link
Copy Markdown
Collaborator

Summary

This PR includes two bug fixes for pinch to zoom functionality for images:

  • Fix pinch-to-zoom out with rotated images: initialRect and initialWidth (used for zoom-out edge clamping) were captured at load time and never updated on rotation. After rotating, the clamping would guide the image toward a stale pre-rotation position, causing it to jump when snapping back to center. Added recalculateInitialRect() which temporarily sizes the image to its fit-to-viewport dimensions for the current rotation, captures the correct initialRect/initialWidth, then restores the actual dimensions without visual flicker.
  • Allow pinch-to-zoom out past fit-to-viewport size: Previously, pinch zoom was clamped at initialWidth (the fit-to-viewport size). Removed that floor so users can continue zooming out. When below initialWidth, uses simple center-based zoom via adjustImageZoomPadding() (matching toolbar zoom-out behavior) instead of cursor-anchored positioning with edge clamping.

Test plan

  • Pinch to zoom in on an unrotated image, then pinch to zoom out — image should smoothly return to center
  • Rotate an image, then pinch to zoom out — image should smoothly return to center (no jumping)
  • Zoom in, rotate, then pinch to zoom out — image should smoothly return to center (no jumping)
  • Pinch to zoom out past the fit-to-viewport size — image should shrink centered in the viewport
  • Verify toolbar zoom in/out buttons still work correctly
  • Verify pinch-to-zoom in still anchors to cursor position correctly

@kduncanhsu kduncanhsu requested a review from a team as a code owner May 29, 2026 22:51
@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.


Duncan Hsu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@kduncanhsu kduncanhsu marked this pull request as draft May 29, 2026 22:51
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