mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 09:39:57 +00:00
Only adjust the camera barcode scanning live stream picture size once (fixes #734)
This commit is contained in:
parent
2e625f330d
commit
e897570968
@ -1,5 +1,6 @@
|
|||||||
Grocy.Components.BarcodeScanner = { };
|
Grocy.Components.BarcodeScanner = { };
|
||||||
|
|
||||||
|
Grocy.Components.BarcodeScanner.LiveVideoSizeAdjusted = false;
|
||||||
Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
|
Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
|
||||||
{
|
{
|
||||||
var track = Quagga.CameraAccess.getActiveTrack();
|
var track = Quagga.CameraAccess.getActiveTrack();
|
||||||
@ -28,18 +29,26 @@ Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reduce the height of the video, if it's heigher than then the viewport
|
// Reduce the height of the video, if it's heigher than then the viewport
|
||||||
var bc = document.getElementById('barcodescanner-container');
|
if (!Grocy.Components.BarcodeScanner.LiveVideoSizeAdjusted)
|
||||||
if (bc) {
|
{
|
||||||
var bcAspectRatio = bc.offsetWidth / bc.offsetHeight;
|
var bc = document.getElementById('barcodescanner-container');
|
||||||
var settings = track.getSettings();
|
if (bc)
|
||||||
if (bcAspectRatio > settings.aspectRatio) {
|
{
|
||||||
var v = document.querySelector('#barcodescanner-livestream video')
|
var bcAspectRatio = bc.offsetWidth / bc.offsetHeight;
|
||||||
if (v) {
|
var settings = track.getSettings();
|
||||||
var c = document.querySelector('#barcodescanner-livestream canvas')
|
if (bcAspectRatio > settings.aspectRatio)
|
||||||
var newWidth = v.clientWidth / bcAspectRatio * settings.aspectRatio + 'px';
|
{
|
||||||
v.style.width = newWidth;
|
var v = document.querySelector('#barcodescanner-livestream video')
|
||||||
c.style.width = newWidth;
|
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.LiveVideoSizeAdjusted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user