Remove toggling of torch, as it's not working

and add resize of video to fit in viewport hieght
This commit is contained in:
Michael Neuendorf 2020-03-29 13:05:13 +02:00
parent 0f2f6a7194
commit 885c294443
2 changed files with 25 additions and 7 deletions

View File

@ -260,8 +260,15 @@ input::-webkit-inner-spin-button {
}
/* Barcodescanner Quagga */
#barcodescanner-container {
max-height: 90vw;
}
#livestream-container {
max-height: 100%;
}
#barcodescanner-livestream video {
width: 100%;
}
#barcodescanner-livestream canvas {
width: 100%;

View File

@ -11,12 +11,26 @@ Grocy.Components.BarcodeScanner.CheckCapabilities = function()
var canTorch = typeof capabilities.torch === 'boolean' && capabilities.torch
var node = document.querySelector('.torch');
if (node) {
node.style.display = canTorch ? 'block' : 'none';
node.style.display = canTorch ? 'inline-block' : 'none';
}
// Reduce the height of the video, if it's heigher than then the viewport
var bc = document.getElementById('barcodescanner-container');
if (bc) {
var bcAspectRatio = bc.offsetWidth / bc.offsetHeight;
var settings = track.getSettings();
if (bcAspectRatio > settings.aspectRatio) {
var v = document.querySelector('#barcodescanner-livestream video')
if (v) {
var c = document.querySelector('#barcodescanner-livestream canvas')
var newWidth = v.clientWidth / bcAspectRatio * settings.aspectRatio + 'px';
v.style.width = newWidth;
c.style.width = newWidth;
}
}
}
}
Grocy.Components.BarcodeScanner.TorchState = false;
Grocy.Components.BarcodeScanner.StartScanning = function()
{
Grocy.Components.BarcodeScanner.DecodedCodesCount = 0;
@ -28,8 +42,6 @@ Grocy.Components.BarcodeScanner.StartScanning = function()
type: "LiveStream",
target: document.querySelector("#barcodescanner-livestream"),
constraints: {
// width: 436,
// height: 327,
facingMode: "environment"
}
},
@ -180,11 +192,10 @@ $(document).on("click", "#barcodescanner-start-button", function(e)
className: 'btn-warning responsive-button torch',
callback: function()
{
Grocy.Components.BarcodeScanner.TorchState = !Grocy.Components.BarcodeScanner.TorchState;
Quagga.CameraAccess.getActiveTrack().applyConstraints({
advanced: [
{
torch: Grocy.Components.BarcodeScanner.TorchState
torch: true
}
]
});