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

Center the QR code, solution #111

Open
runplay opened this issue Apr 3, 2018 · 2 comments
Open

Center the QR code, solution #111

runplay opened this issue Apr 3, 2018 · 2 comments

Comments

@runplay
Copy link

runplay commented Apr 3, 2018

Hi, did post this before but to a closed one #2

As wanted to use the library, I have made a tweak to fix the issue this just one line change if you want to include into the official version.

just replace line 404 in qrious.js

from:
var offset = this.getOffset(frame);

to:
var offset=parseInt((this.element.width-(frame.width*moduleSize))/2);

tested across a variety of sizes and content

@alieslamifard
Copy link

why not done yet?!! it's an old issue with simple solution!

@blizzardengle
Copy link

blizzardengle commented Oct 26, 2019

This is actually implemented already but is blocked from ever running. Take a look at the getOffset() function starting at line 330. If you provide a padding value that value is what is returned here, if you fail to provide a padding value 0 is returned anyways so this centering math is never run. Change the padding if() check to this code and it works properly:

if (padding != null) {
    if(padding > 0){
        return padding;
    }
}

With this change you leave line 404 alone and don't add your code. The getOffset() function already has it.

blizzardengle added a commit to blizzardengle/qrious that referenced this issue Oct 26, 2019
Fixes the code to properly center the QR code when no padding is provided.
blizzardengle added a commit to blizzardengle/qrious that referenced this issue Oct 26, 2019
Fixes the code to properly center the QR code when no padding is provided.
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

No branches or pull requests

3 participants