fix(camera): keep zoom slider off the ultra-wide lens - #728
Merged
Merged
Conversation
The Android slider is a SeekBar with an int progress, so feeding it raw zoom ratios truncated every value: on a device whose minimum zoom is 0.7 (ultra wide lens) the slider could only produce 0.7/1.7/2.7, making 1x unreachable and pinning the camera to the ultra wide lens once the value was persisted. Map the slider to a logarithmic 0..100 scale snapped to the neutral zoom, and clamp both the stored and the pinch reported zoom to the range of the current device. Refs #693 Co-Authored-By: Claude Opus 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.
Summary
0..100scale instead of raw zoom ratios. On Androidslideris anandroid.widget.SeekBarwhose progress is anint, so raw ratios were truncated: on a device reporting a minimum zoom of0.7(ultra wide lens) the only reachable values were0.7 / 1.7 / 2.7 …—1xcould not be selected, and0.7xwas the easiest value to land on.1xis always reachable whatever the device reports.defaultZoomis clamped to the range of the current device on camera open, and the ratio reported by the native pinch handler (which is not coerced by the plugin) is clamped before being persisted. A stale or out of range value can no longer pin the camera to the ultra wide lens on every launch.app/utils/cameraZoom.tsso they can be unit tested.Testing
npx vitest run app/utils/cameraZoom.test.ts— round trip, neutral snap, exact1xreachability over several device ranges, clamping of out of range and non finite values, degenerate ranges.yarn svelte-check— clean.1xminimum zoom (Pixel 7): camera opens at1x, the floating label tracks the thumb, sliding reaches exactly1x, and the chosen zoom survives a relaunch.Refs #693