Repository navigation
Zoom percentage fix and zoom out more - #1869
Open
SebastianEggli wants to merge 2 commits into
Open
SebastianEggli wants to merge 2 commits into
SebastianEggli wants to merge 2 commits into
Conversation
Lower the minimum editor zoom from 10% to 1% via a shared MIN_ZOOM_PERCENT constant, use a finer slider step, and step zoom proportionally below 20% so keyboard zoom doesn't overshoot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mage The zoom readout, percent input and keyboard shortcuts compared the on-screen size to the uncropped, unrotated original, while the editor renders the cropped/oriented image. Typing 100% on a cropped image magnified it by origW/cropW while still reading 100%, and on a 90° rotated 3:2 image the readout jumped to ~67%. Centralize the math in utils/zoom.ts (physical percent = renderScale * transformScale * dpr), store the fit render scale, clamp 1%-200% in physical pixels for every DPR, and track devicePixelRatio reactively via a new useDevicePixelRatio hook. Add vitest with table-driven tests across monitor profiles, images and crop/rotation states, plus regression cases for the old formulas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Type of Change
Changes Made
src/utils/zoom.tswith the shared math:percent = renderScale × transformScale × dpr. Also contains the 1%–200% limits, zoom steps, andzoomReferenceSize(the cropped/oriented size the editor draws).baseRenderSize.renderScale).BottomBar,useEditorActions.handleZoomChangeanduseKeyboardShortcuts(step, cycle, in/out) all use it instead oforiginalSize.useDevicePixelRatiohook, used by the editor, bottom bar and settings panel. The readout and limits update when the window moves to another monitor or the OS scale changes. The settings panel's previous listener only caught the first change.vitestas a dev dependency and annpm testscript.Testing
Added
src/utils/zoom.test.ts, run withnpm test, about 2,000 cases. It's table-driven across:Each combination checks that 100% is 1:1, that a typed percent reads back the same, fit, and the limits. Two regression tests reproduce the old 67% and "magnified while showing 100%" errors.
Manual check: open a 1-pixel black/white checkerboard image and type
100. The pattern looks crisp and even, with no stripes or blur, and the readout stays at 100%, including after rotating and cropping.Test Configuration:
Checklist
AI Disclaimer:
Please state the involvement of AI in this PR: