Skip to content

Commit 735faa6

Browse files
feat: Scanner
1 parent 5ceaf29 commit 735faa6

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

src/components/Scanner/scanner.tsx

+3-24
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ class Scanner extends Component<ScannerProps, ScannerState> {
2929
inputStream: {
3030
type: "LiveStream",
3131
constraints: {
32-
width,
33-
height,
3432
aspectRatio: { ideal: height / width },
3533
facingMode: newFacingMode,
34+
height: { min: 480, ideal: height, max: 1080 },
3635
},
3736
},
3837
locator: {
@@ -59,34 +58,15 @@ class Scanner extends Component<ScannerProps, ScannerState> {
5958
);
6059
};
6160

62-
updateVideoSize() {
63-
const video = document.querySelector("video");
64-
if (video) {
65-
const aspectRatio = video.videoWidth / video.videoHeight;
66-
const windowAspectRatio = window.innerWidth / window.innerHeight;
67-
68-
if (aspectRatio > windowAspectRatio) {
69-
video.style.width = "100%";
70-
video.style.height = "auto";
71-
} else {
72-
video.style.width = "auto";
73-
video.style.height = "100%";
74-
}
75-
}
76-
}
77-
7861
componentDidMount() {
7962
const { facingMode } = this.state;
8063
console.log(facingMode);
8164
this.handleClick();
8265
Quagga.onDetected(this._onDetected);
83-
this.updateVideoSize();
84-
window.addEventListener("resize", this.updateVideoSize);
8566
}
8667

8768
componentWillUnmount() {
8869
Quagga.offDetected(this._onDetected);
89-
window.removeEventListener("resize", this.updateVideoSize);
9070
}
9171

9272
_onDetected = (result: any) => {
@@ -109,9 +89,8 @@ class Scanner extends Component<ScannerProps, ScannerState> {
10989
const vid: React.CSSProperties = {
11090
position: "fixed",
11191
zIndex: 999,
112-
left: "50%",
113-
top: "50%",
114-
transform: "translate(-50%, -50%)",
92+
left: 0,
93+
top: 0,
11594
};
11695

11796
return (

0 commit comments

Comments
 (0)