|
7 | 7 | --> |
8 | 8 | <video |
9 | 9 | ref="video" |
10 | | - v-show="shouldScan" |
| 10 | + :class="{ 'qrcode-stream-camera--hidden': !shouldScan }" |
11 | 11 | class="qrcode-stream-camera" |
12 | 12 | autoplay |
13 | 13 | muted |
@@ -181,19 +181,6 @@ export default { |
181 | 181 | } |
182 | 182 | }, |
183 | 183 |
|
184 | | - onLocate(location) { |
185 | | - if (this.trackRepaintFunction === undefined || location === null) { |
186 | | - this.clearCanvas(this.$refs.trackingLayer); |
187 | | - } else { |
188 | | - const video = this.$refs.video; |
189 | | - const canvas = this.$refs.trackingLayer; |
190 | | -
|
191 | | - if (video !== undefined && canvas !== undefined) { |
192 | | - this.repaintTrackingLayer(video, canvas, location); |
193 | | - } |
194 | | - } |
195 | | - }, |
196 | | -
|
197 | 184 | onLocate(detectedCodes) { |
198 | 185 | const canvas = this.$refs.trackingLayer; |
199 | 186 | const video = this.$refs.video; |
@@ -318,4 +305,20 @@ export default { |
318 | 305 | display: block; |
319 | 306 | object-fit: cover; |
320 | 307 | } |
| 308 | +/* When a camera stream is loaded, we assign the stream to the `video` |
| 309 | + * element via `video.srcObject`. At this point the element used to be |
| 310 | + * hidden with `v-show="false"` aka. `display: none`. We do that because |
| 311 | + * at this point the videos dimensions are not known yet. We have to |
| 312 | + * wait for the `loadeddata` event first. Only after that event we |
| 313 | + * display the video element. Otherwise the elements size awkwardly flickers. |
| 314 | + * |
| 315 | + * However, it appears in iOS 15 all iOS browsers won't properly render |
| 316 | + * the video element if the `video.srcObject` was assigned *while* the |
| 317 | + * element was hidden with `display: none`. Using `visibility: hidden` |
| 318 | + * instead seems to have fixed the problem though. |
| 319 | + */ |
| 320 | +.qrcode-stream-camera--hidden { |
| 321 | + visibility: hidden; |
| 322 | + position: absolute; |
| 323 | +} |
321 | 324 | </style> |
0 commit comments