feat: Scanner

This commit is contained in:
Philip 2023-05-08 19:05:48 +02:00
parent 303a8e01ce
commit b023eeecb2
2 changed files with 12 additions and 3 deletions

View file

@ -21,14 +21,18 @@ class Scanner extends Component<ScannerProps, ScannerState> {
const newFacingMode = facingMode === "environment" ? "user" : "environment";
this.setState({ facingMode: newFacingMode });
const scaleFactor = 0.75;
const width = window.innerWidth * scaleFactor;
const height = window.innerHeight * scaleFactor;
Quagga.init(
{
inputStream: {
type: "LiveStream",
constraints: {
width: window.innerWidth * window.devicePixelRatio,
height: window.innerHeight * window.devicePixelRatio,
aspectRatio: { ideal: window.innerHeight / window.innerWidth },
width,
height,
aspectRatio: { ideal: height / width },
facingMode: newFacingMode,
},
},

5
types/quagga.d.ts vendored Normal file
View file

@ -0,0 +1,5 @@
declare module "quagga" {
const Quagga: any;
export default Quagga;
}