Skip to content

Commit 679cf56

Browse files
committed
Height calculation optimization
Height calculation optimization
1 parent bc9c2a4 commit 679cf56

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

dist/easy.qrcode.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "easyqrcodejs",
3-
"version": "4.4.10",
3+
"version": "4.4.12",
44
"description": "Cross-browser QRCode generator for pure javascript. Support Canvas, SVG and Table drawing methods. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support Angular, Vue.js, React, Next.js, Svelte framework. Support binary(hex) data mode.(Running with DOM on client side)",
55
"main": "dist/easy.qrcode.min.js",
66
"scripts": {},

readme.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ EasyQRCodeJS 是一个功能丰富的跨浏览器的纯 JavaScript QRCode 生成
2828
- [Svelte Support](#svelte-support)
2929
- [FQA](#fqa)
3030
- [Q1. Tainted canvases may not be exported.](#q1-tainted-canvases-may-not-be-exported)
31+
- [Q2. How to show the QRCode image only after rendering is done?](#q2-how-to-show-the-qrcode-image-only-after-rendering-is-done)
3132
- [Browser Compatibility](#browser-compatibility)
3233
- [License](#license)
3334
- [EasyQRCodeJS-Premium](#easyqrcodejs-premium)
@@ -774,6 +775,16 @@ When use canvas drawer, Canvas toDataURL function does not allow load cross doma
774775
Use base64 image.
775776
776777
778+
### Q2. How to show the QRCode image only after rendering is done?
779+
780+
```JS
781+
onRenderingStart: function(qrCodeOptions) {
782+
qrCodeOptions._element.style.display = 'none';
783+
},
784+
onRenderingEnd: function(qrCodeOptions) {
785+
qrCodeOptions._element.style.display = 'block';
786+
},
787+
```
777788
778789
## Browser Compatibility
779790
IE6+, Chrome, Firefox, Safari, Opera, Mobile Safari, Android, Windows Mobile, ETC.

src/easy.qrcode.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Cross-browser QRCode generator for pure javascript. Support Canvas, SVG and Table drawing methods. Support Dot style, Logo, Background image, Colorful, Title etc. settings. Support Angular, Vue.js, React, Next.js, Svelte framework. Support binary(hex) data mode.(Running with DOM on client side)
55
*
6-
* Version 4.4.10
6+
* Version 4.4.12
77
*
88
* @author [ [email protected] ]
99
*
@@ -1430,11 +1430,6 @@
14301430
// var _elImage = this._elImage;
14311431
var _htOption = this._htOption;
14321432

1433-
if (!_htOption.title && !_htOption.subTitle) {
1434-
_htOption.height -= _htOption.titleHeight;
1435-
_htOption.titleHeight = 0;
1436-
}
1437-
14381433
var nCount = oQRCode.getModuleCount();
14391434
var nWidth = Math.round(_htOption.width / nCount);
14401435
var nHeight = Math.round((_htOption.height - _htOption.titleHeight) / nCount);
@@ -2026,6 +2021,10 @@
20262021
}
20272022
}
20282023

2024+
if (!this._htOption.title && !this._htOption.subTitle) {
2025+
this._htOption.titleHeight = 0;
2026+
}
2027+
20292028
if (this._htOption.version < 0 || this._htOption.version > 40) {
20302029
console.warn("QR Code version '" + this._htOption.version + "' is invalidate, reset to 0")
20312030
this._htOption.version = 0;
@@ -2116,6 +2115,8 @@
21162115
this._el = el;
21172116
this._oQRCode = null;
21182117

2118+
this._htOption._element = el;
2119+
21192120
var _htOptionClone = {};
21202121
for (var i in this._htOption) {
21212122
_htOptionClone[i] = this._htOption[i];

0 commit comments

Comments
 (0)