fix(scanner): center barcode target on mobile#125
Merged
Conversation
The fixed aspect-[3/2] container plus !size-full + object-cover cropped the camera feed, while html5-qrcode draws its scan-box overlay against the video element's box. With cropping, center-of-element drifted from center-of-visible-frame, leaving the target far from where the camera was actually decoding. Drop the forced aspect/cover styling so the video renders at its native ratio, drop the aspectRatio: 1.5 getUserMedia constraint, and reshape qrbox into a symmetric landscape band (90% wide, 45% of the short side tall) so it sits centered on portrait and landscape streams. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Preview deployment
|
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
aspect-[3/2]+!size-full+object-coverstyling on the camera feed so the video renders at its native ratio. With cropping in place, html5-qrcode's scan-box overlay drew at the center of the video element while the user saw a different, cropped region — making the target appear off-center and almost impossible to line up with a barcode on mobile.aspectRatio: 1.5getUserMediaconstraint; phones rarely honor it cleanly and it compounded the misalignment.qrboxinto a symmetric landscape band (90% wide, ~45% of the short side tall) so it sits centered on both portrait and landscape streams.Test plan
/ingredientson iOS Safari, tap "Scan barcode", confirm the highlighted target sits over the middle of the camera frame and a real barcode scans on first hit.🤖 Generated with Claude Code