qrious icon indicating copy to clipboard operation
qrious copied to clipboard

Center the QR code, solution

Open runplay opened this issue 6 years ago • 2 comments

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

runplay avatar Apr 03 '18 15:04 runplay

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

alieslamifard avatar Jul 30 '18 05:07 alieslamifard

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 avatar Oct 26 '19 16:10 blizzardengle