File tree Expand file tree Collapse file tree 3 files changed +16
-14
lines changed
Expand file tree Collapse file tree 3 files changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -61,12 +61,12 @@ class Test extends Component {
6161
6262### Events
6363
64- | Prop | Argument | Description |
65- | ----------- | ---------------- | ----------------------------------------------------------------------------------------------- |
66- | onScan | ` result ` | Scan event handler. Called every scan with the decoded value or ` null ` if no QR code was found. |
67- | onError | ` Error ` | Called when an error occurs. |
68- | onLoad | none | Called when the component is ready for use. |
69- | onImageLoad | img onLoad event | Called when the image in legacyMode is loaded. |
64+ | Prop | Argument | Description |
65+ | ----------- | ---------------- | --------------------------------------------------------------------------------------------------------------- |
66+ | onScan | ` result ` | Scan event handler. Called every scan with the decoded value or ` null ` if no QR code was found. |
67+ | onError | ` Error ` | Called when an error occurs. |
68+ | onLoad | ` object ` | Called when the component is ready for use. Object properties are ` mirrorVideo ` : boolean, ` streamLabel ` : string |
69+ | onImageLoad | img onLoad event | Called when the image in legacyMode is loaded. |
7070
7171### Options
7272
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ module.exports = class Reader extends Component {
164164 }
165165 handleVideo ( stream ) {
166166 const { preview } = this . els
167+ const { facingMode } = this . props
167168
168169 // Preview element hasn't been rendered so wait for it.
169170 if ( ! preview ) {
@@ -192,17 +193,16 @@ module.exports = class Reader extends Component {
192193
193194 preview . addEventListener ( 'loadstart' , this . handleLoadStart )
194195
195- const facingUserPattern = getFacingModePattern ( 'user' )
196- const isUserFacing = facingUserPattern . test ( streamTrack . label )
197- this . setState ( { mirrorVideo : isUserFacing } )
196+ this . setState ( { mirrorVideo : facingMode == 'user' , streamLabel : streamTrack . label } )
198197 }
199198 handleLoadStart ( ) {
200199 const { delay, onLoad } = this . props
200+ const { mirrorVideo, streamLabel } = this . state
201201 const preview = this . els . preview
202202 preview . play ( )
203203
204204 if ( typeof onLoad == 'function' ) {
205- onLoad ( )
205+ onLoad ( { mirrorVideo , streamLabel } )
206206 }
207207
208208 if ( typeof delay == 'number' ) {
You can’t perform that action at this time.
0 commit comments