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.LiveVideoSizeAdjusted = false;
|
||||
Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
|
||||
{
|
||||
var track = Quagga.CameraAccess.getActiveTrack();
|
||||
@ -28,19 +29,27 @@ Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
|
||||
}
|
||||
|
||||
// Reduce the height of the video, if it's heigher than then the viewport
|
||||
if (!Grocy.Components.BarcodeScanner.LiveVideoSizeAdjusted)
|
||||
{
|
||||
var bc = document.getElementById('barcodescanner-container');
|
||||
if (bc) {
|
||||
if (bc)
|
||||
{
|
||||
var bcAspectRatio = bc.offsetWidth / bc.offsetHeight;
|
||||
var settings = track.getSettings();
|
||||
if (bcAspectRatio > settings.aspectRatio) {
|
||||
if (bcAspectRatio > settings.aspectRatio)
|
||||
{
|
||||
var v = document.querySelector('#barcodescanner-livestream video')
|
||||
if (v) {
|
||||
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