@@ -29,10 +29,9 @@ class Scanner extends Component<ScannerProps, ScannerState> {
29
29
inputStream : {
30
30
type : "LiveStream" ,
31
31
constraints : {
32
- width,
33
- height,
34
32
aspectRatio : { ideal : height / width } ,
35
33
facingMode : newFacingMode ,
34
+ height : { min : 480 , ideal : height , max : 1080 } ,
36
35
} ,
37
36
} ,
38
37
locator : {
@@ -59,34 +58,15 @@ class Scanner extends Component<ScannerProps, ScannerState> {
59
58
) ;
60
59
} ;
61
60
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
-
78
61
componentDidMount ( ) {
79
62
const { facingMode } = this . state ;
80
63
console . log ( facingMode ) ;
81
64
this . handleClick ( ) ;
82
65
Quagga . onDetected ( this . _onDetected ) ;
83
- this . updateVideoSize ( ) ;
84
- window . addEventListener ( "resize" , this . updateVideoSize ) ;
85
66
}
86
67
87
68
componentWillUnmount ( ) {
88
69
Quagga . offDetected ( this . _onDetected ) ;
89
- window . removeEventListener ( "resize" , this . updateVideoSize ) ;
90
70
}
91
71
92
72
_onDetected = ( result : any ) => {
@@ -109,9 +89,8 @@ class Scanner extends Component<ScannerProps, ScannerState> {
109
89
const vid : React . CSSProperties = {
110
90
position : "fixed" ,
111
91
zIndex : 999 ,
112
- left : "50%" ,
113
- top : "50%" ,
114
- transform : "translate(-50%, -50%)" ,
92
+ left : 0 ,
93
+ top : 0 ,
115
94
} ;
116
95
117
96
return (
0 commit comments