Skip to content

Commit 4421917

Browse files
committed
Revert "Removed baarcode scanner inbox, as we now have enough performance to apply the decoder to the full image"
This reverts commit de0832b.
1 parent 25c8660 commit 4421917

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

assets/controllers/pages/barcode_scan_controller.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,29 @@ export default class extends Controller {
3333
connect() {
3434
console.log('Init Scanner');
3535

36+
//This function ensures, that the qrbox is 70% of the total viewport
37+
let qrboxFunction = function(viewfinderWidth, viewfinderHeight) {
38+
let minEdgePercentage = 0.7; // 70%
39+
let minEdgeSize = Math.min(viewfinderWidth, viewfinderHeight);
40+
let qrboxSize = Math.floor(minEdgeSize * minEdgePercentage);
41+
return {
42+
width: qrboxSize,
43+
height: qrboxSize
44+
};
45+
}
46+
3647
//Try to get the number of cameras. If the number is 0, then the promise will fail, and we show the warning dialog
3748
Html5Qrcode.getCameras().catch((devices) => {
3849
document.getElementById('scanner-warning').classList.remove('d-none');
3950
});
4051

4152
this._scanner = new Html5QrcodeScanner(this.element.id, {
4253
fps: 10,
54+
qrbox: qrboxFunction,
55+
experimentalFeatures: {
56+
//This option improves reading quality on android chrome
57+
useBarCodeDetectorIfSupported: true
58+
}
4359
}, false);
4460

4561
this._scanner.render(this.onScanSuccess.bind(this));

0 commit comments

Comments
 (0)