mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
fix(qrcode): calculate margins using real size instead of DOM offset
Replaces the dependency on `offsetWidth` and `offsetHeight` with a deterministic calculation based on module count and cell size. This prevents incorrect (huge) margins when the QR code is generated inside a hidden container where offset dimensions are 0. Fixes: Margin values calculation in QRCode drawing logic. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
fc25801811
commit
e4e07ad7e8
1 file changed
+2
-2
+2
-2
@@ -364,8 +364,8 @@ if (hasDocument) {
|
||||
|
||||
// Fix the margin values as real size.
|
||||
var elTable = _el.childNodes[0];
|
||||
var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2;
|
||||
var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2;
|
||||
var nLeftMarginTable = (_htOption.width - (nCount * nWidth)) / 2;
|
||||
var nTopMarginTable = (_htOption.height - (nCount * nHeight)) / 2;
|
||||
|
||||
if (nLeftMarginTable > 0 && nTopMarginTable > 0) {
|
||||
updateQrCodeContainerStyles(_el, {
|
||||
|
||||
Reference in new issue
Block a user