Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set width of QuaggaJs to 100%?

I'm trying to build a barcode scanner for a mobile web application.
Now i´d like to set the width of the "camera viewport" to fit into my div.

So in QuaggaJs you can set the size of the livestream like this:

Quagga.init({
    inputStream : {
        name : "Live",
        type : "LiveStream",
        target: document.querySelector('#interactive'),
        constraints: {
            width: 200,
            height: 200,
            facing: "environment" // or user
        }
    },

If you "comment" the width and height the size will be bigger than my mobile screen.
So, how can i set the viewport to just fill my div?

HTML (Bootstrap)

<div class="container">
  <div id="interactive" class="viewport"></div>
  <div id="interactive" class="viewport col-md-12"></div>
  <div id="interactive" class="viewport" style="width: 100%;"></div>
</div>
like image 670
Björn C Avatar asked Oct 26 '25 14:10

Björn C


2 Answers

You can set height and width whit this properties.

var w = window.innerWidth;

var h = window.innerHeight;

innerHeight and innerWidth are you screen dimensions

like image 77
Mr.Bruno Avatar answered Oct 28 '25 03:10

Mr.Bruno


I'm using Quagga in Angular project and I handled sizing with code below:

HTML:

<div id="barcode_scanner"></div>

CSS:

#barcode_scanner {
    &::ng-deep video {
        width: 100%;
    }
     ::ng-deep canvas {
        position: absolute;
        z-index: 1000;
        right: 0;
        width: 100%;
    }
}
like image 39
Vala Khosravi Avatar answered Oct 28 '25 04:10

Vala Khosravi