Skip to content

fix(scanner): center barcode target on mobile#125

Merged
hyldmo merged 1 commit into
mainfrom
hyldmo/fix-mobile-scanner-alignment
May 9, 2026
Merged

fix(scanner): center barcode target on mobile#125
hyldmo merged 1 commit into
mainfrom
hyldmo/fix-mobile-scanner-alignment

Conversation

@hyldmo
Copy link
Copy Markdown
Owner

@hyldmo hyldmo commented May 9, 2026

Summary

  • Drop the fixed aspect-[3/2] + !size-full + object-cover styling 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.
  • Remove the aspectRatio: 1.5 getUserMedia constraint; phones rarely honor it cleanly and it compounded the misalignment.
  • Reshape qrbox into a symmetric landscape band (90% wide, ~45% of the short side tall) so it sits centered on both portrait and landscape streams.

Test plan

  • Open /ingredients on 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.
  • Same on Android Chrome.
  • Desktop sanity check (laptop webcam) — target visible, scanning still works.

🤖 Generated with Claude Code

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>
@hyldmo hyldmo merged commit a3181f6 into main May 9, 2026
2 checks passed
@hyldmo hyldmo deleted the hyldmo/fix-mobile-scanner-alignment branch May 9, 2026 15:20
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Preview deployment

URL https://hyldmo-fix-mobile-scanner-al.macromaxxing.pages.dev
Branch hyldmo/fix-mobile-scanner-alignment
Commit 2dea5df

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.

1 participant