Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix QR Code Resizing Visually #6

Merged
merged 1 commit into from
Aug 5, 2023
Merged

Fix QR Code Resizing Visually #6

merged 1 commit into from
Aug 5, 2023

Conversation

lyqht
Copy link
Owner

@lyqht lyqht commented Aug 5, 2023

Resolves #4

Context

Previously in the app, the QR code resizes as the user sets the width & height, causing significant layout shift. This is unpleasant for UX. It was done because the dom-to-image library requires the element to be visible in order to convert the element into an export format PNG/SVG/Blob.

Solution

This issue is fixed by:

  • Ensure qr code shown to users is always fixed width & height
  • Added a function to get element resize scale factor based on given width/height.
  • Before exporting as PNG/SVG/blob, use dom-to-image options to dynamically scale the qr-code image.

Before

At width/height set as 2000px

CleanShot 2023-08-05 at 10 03 28@2x

After

At width/height set as 2000px

CleanShot 2023-08-05 at 10 02 54@2x

@vercel
Copy link

vercel bot commented Aug 5, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
styled-qr-code-generator ✅ Ready (Inspect) Visit Preview Aug 5, 2023 5:00pm

@lyqht lyqht merged commit 8066534 into main Aug 5, 2023
1 check passed
@lyqht lyqht deleted the feat/qr-no-resize branch August 5, 2023 17:02
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.

QR Code should not be resized visually after changing width and height values
1 participant