Skip to content

fix: single-click zoom now toggles between fit-to-window and 100% pixels - #1640

Open
chuckhenrich wants to merge 1 commit into
CyberTimon:mainfrom
chuckhenrich:fix/single-click-zoom-toggle
Open

fix: single-click zoom now toggles between fit-to-window and 100% pixels#1640
chuckhenrich wants to merge 1 commit into
CyberTimon:mainfrom
chuckhenrich:fix/single-click-zoom-toggle

Conversation

@chuckhenrich

@chuckhenrich chuckhenrich commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Description

Single-click zoom previously toggled between fit-to-window and approximately 2× the fit-to-window scale. The zoom target therefore varied with window size and had no fixed reference point, making it difficult to predict where the click would land.

This fix changes single-click to toggle between fit-to-window and 100% zoom (1 image pixel = 1 screen pixel), consistent with standard photo editing tool conventions.

Closes #1638
Closes #1639

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Performance improvement
  • Code refactoring
  • Documentation update
  • UI/UX improvement
  • Build/CI or Dependency update

Changes Made

  • src/components/panel/Editor.tsx: Rewrote handleClick toggle logic. The zoom target is now computed as originalSize.width / (baseRenderSize.width * dpr) — the exact internal scale for 100% pixels — rather than Math.min(currentScale * 2, maxScaleRef.current). The toggle condition checks whether the current scale is within 5% of the 100% target rather than using a hardcoded > 1.01 threshold.
  • src/components/panel/BottomBar.tsx: Updated currentOriginalPercent to compute from zoom and baseRenderSize.width rather than displaySize.width, ensuring the displayed percentage is consistent with the zoom target used in handleClick.
  • src/components/panel/Editor.tsx: Also removes the erroneous Math.max(20, maxScale) floor in transformConfig which was causing the scroll wheel zoom ceiling to scale with window size rather than being fixed at 200% pixels.

Screenshots/Videos

Testing

  • These changes were tested locally by a human and confirmed to work.
  • I haven't added any automated tests to the code because the codebase currently lacks a test suite.

Test Configuration:

  • OS: Ubuntu 24.04 x86_64
  • Hardware: Intel 16-thread CPU, GeForce RTX 2060 Rev. A

Checklist

  • My code follows the project's code style
  • I haven't added unnecessary AI-generated code comments
  • My changes generate no new warnings or errors

Additional Notes

The BottomBar.tsx change is a prerequisite for correct display of the 100% zoom level. Without it, floating point drift between the zoom target computation and the display percentage computation caused the display to show 99% instead of 100%.

The maxScale fix (removing Math.max(20, maxScale) in transformConfig) is included in this PR as it was a prerequisite for the correct single-click zoom target computation. It also independently fixes #1638, where the scroll wheel zoom ceiling scaled proportionally with window size rather than being fixed.

AI Disclaimer:

Please state the involvement of AI in this PR:

  • This PR is created by an AI agent
  • This PR is mostly AI-generated but edited/merged together by a human
  • This PR was handwritten with AI assistance (spell check, logic suggestions, error resolving)
  • This PR contains only blood, sweat, and coffee (AI-free)

Previously, single-click toggled between fit-to-window and 2× fit,
which varied with window size and had no fixed reference point.

Now toggles between fit-to-window and 100% zoom (1:1 pixels), consistent
with standard photo editor conventions.

Fixes CyberTimon#1639
@chuckhenrich
chuckhenrich force-pushed the fix/single-click-zoom-toggle branch from 5483a8c to b15a9d7 Compare September 1, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant