Skip to content

Commit

Permalink
Bug fix on scanner#clear() (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
mebjas authored Jul 18, 2020
1 parent 100678c commit 665041b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Version 1.1.8
+ Bug fix on `Html5QrcodeScanner#clear()`

### Version 1.1.7
+ `Html5QrcodeScanner#clear()` returns a `Promise`.

Expand Down
11 changes: 8 additions & 3 deletions html5-qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -945,13 +945,14 @@ class Html5QrcodeScanner {
const mainContainer = document.getElementById(this.elementId);
if (mainContainer) {
mainContainer.innerHTML = "";
this.__resetBasicLayout(mainContainer);
}
}

if (this.html5Qrcode) {
return new Promise((resolve, reject) => {
if (this.html5Qrcode._isScanning()) {
this.html5Qrcode.stop().then(_ => {
if ($this.html5Qrcode._isScanning) {
$this.html5Qrcode.stop().then(_ => {
$this.html5Qrcode.clear();
emptyHtmlContainer();
resolve();
Expand Down Expand Up @@ -989,7 +990,11 @@ class Html5QrcodeScanner {
parent.appendChild(qrCodeDashboard);

this.__setupInitialDashboard(qrCodeDashboard);
}
}

__resetBasicLayout(parent) {
parent.style.border = "none";
}

__setupInitialDashboard(dashboard) {
this.__createSection(dashboard);
Expand Down
2 changes: 1 addition & 1 deletion minified/html5-qrcode.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html5-qrcode",
"version": "1.1.7",
"version": "1.1.8",
"description": "a cross platform HTML5 QR Code scanner",
"main": "html5-qrcode.js",
"scripts": {
Expand Down
11 changes: 9 additions & 2 deletions transpiled/html5-qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -1030,13 +1030,15 @@ var Html5QrcodeScanner = /*#__PURE__*/function () {

if (mainContainer) {
mainContainer.innerHTML = "";

_this4.__resetBasicLayout(mainContainer);
}
};

if (this.html5Qrcode) {
return new Promise(function (resolve, reject) {
if (_this4.html5Qrcode._isScanning()) {
_this4.html5Qrcode.stop().then(function (_) {
if ($this.html5Qrcode._isScanning) {
$this.html5Qrcode.stop().then(function (_) {
$this.html5Qrcode.clear();
emptyHtmlContainer();
resolve();
Expand Down Expand Up @@ -1083,6 +1085,11 @@ var Html5QrcodeScanner = /*#__PURE__*/function () {

this.__setupInitialDashboard(qrCodeDashboard);
}
}, {
key: "__resetBasicLayout",
value: function __resetBasicLayout(parent) {
parent.style.border = "none";
}
}, {
key: "__setupInitialDashboard",
value: function __setupInitialDashboard(dashboard) {
Expand Down

0 comments on commit 665041b

Please sign in to comment.