Skip to content

Commit 2eeced2

Browse files
committed
Update onRenderingStart
# onRenderingStart
1 parent f4ea5a7 commit 2eeced2

File tree

4 files changed

+84
-86
lines changed

4 files changed

+84
-86
lines changed

QRCode.js

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* React Native QRCode generation component. Can generate standard QRCode image or base64 image data url text. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.
55
*
6-
* Version 3.7.1
6+
* Version 3.7.2
77
*
88
* @author [ [email protected] ]
99
*
@@ -1068,10 +1068,10 @@ var Drawing = function(canvas, htOption) {
10681068
* @param {QRCode} oQRCode
10691069
*/
10701070
Drawing.prototype.draw = function(oQRCode) {
1071-
1072-
10731071
var _htOption = this._htOption;
1074-
1072+
if (_htOption.onRenderingStart) {
1073+
_htOption.onRenderingStart(_htOption)
1074+
}
10751075
if (!_htOption.title && !_htOption.subTitle) {
10761076
_htOption.height -= _htOption.titleHeight;
10771077
_htOption.titleHeight = 0;
@@ -1085,17 +1085,13 @@ Drawing.prototype.draw = function(oQRCode) {
10851085

10861086
this._htOption.width = nWidth * nCount;
10871087
this._htOption.height = nHeight * nCount + _htOption.titleHeight;
1088-
var cw = (this._htOption.width + this._htOption.quietZone * 2);
1089-
var ch = (this._htOption.height + this._htOption.quietZone * 2);
1090-
this._canvas.height = ch;
1091-
this._canvas.width = cw;
1088+
this._canvas.height = his._htOption.height + this._htOption.quietZone * 2;
1089+
this._canvas.width = this._htOption.width + this._htOption.quietZone * 2;
10921090

10931091
var autoColorDark = "rgba(0, 0, 0, .6)";
10941092
var autoColorLight = "rgba(255, 255, 255, .7)";
10951093
var notAutoColorLight = "rgba(0,0,0,0)";
10961094

1097-
console.log(this._canvas.width, this._canvas.height);
1098-
10991095
this._oContext = this._canvas.getContext("2d");
11001096
this._oContext.patternQuality = 'best'; //'fast'|'good'|'best'|'nearest'|'bilinear'
11011097
this._oContext.quality = 'best'; //'fast'|'good'|'best'|'nearest'|'bilinear'
@@ -1141,7 +1137,7 @@ Drawing.prototype.draw = function(oQRCode) {
11411137
drawQrcode.call(t, oQRCode);
11421138
});
11431139
bgImg.addEventListener('error', () => {
1144-
console.log("Background image can not load!");
1140+
console.error("Background image can not load!");
11451141
});
11461142
bgImg.src = _htOption.backgroundImage;
11471143

@@ -1155,9 +1151,7 @@ Drawing.prototype.draw = function(oQRCode) {
11551151
}
11561152

11571153
function drawQrcode(oQRCode) {
1158-
if (_htOption.onRenderingStart) {
1159-
_htOption.onRenderingStart(_htOption)
1160-
}
1154+
11611155
for (var row = 0; row < nCount; row++) {
11621156
for (var col = 0; col < nCount; col++) {
11631157
var nLeft = col * nWidth + _htOption.quietZone;
@@ -1255,7 +1249,7 @@ Drawing.prototype.draw = function(oQRCode) {
12551249
}
12561250

12571251
if (_htOption.logo) {
1258-
var img = new CanvasImage(t._canvas);
1252+
var logoImg = new CanvasImage(t._canvas);
12591253
var _this = this;
12601254

12611255
function generateLogoImg(img) {
@@ -1313,19 +1307,17 @@ Drawing.prototype.draw = function(oQRCode) {
13131307
_htOption.onRenderingEnd(_htOption, function() {
13141308
return _this._canvas.toDataURL();
13151309
});
1316-
1317-
13181310
}
13191311
}
13201312

1321-
img.addEventListener('load', () => {
1322-
generateLogoImg(img);
1313+
logoImg.addEventListener('load', () => {
1314+
generateLogoImg(logoImg);
13231315
});
1324-
img.addEventListener('error', () => {
1325-
console.log("Logo image can not load!");
1316+
logoImg.addEventListener('error', () => {
1317+
console.error("Logo image can not load!");
13261318
});
13271319

1328-
img.src = _htOption.logo;
1320+
logoImg.src = _htOption.logo;
13291321
} else {
13301322
this._bIsPainted = true;
13311323
if (_htOption.quietZone > 0 && _htOption.quietZoneColor) {

0 commit comments

Comments
 (0)