Skip to content

Commit 51540f7

Browse files
committed
feat(camera-prop): add auto option
Passing `auto` requests the rear camera by default and will fallback to whatever kind of camera is installed otherwise. This is the same behavior `rear` had before. `rear` now force requests the rear camera. The makes `rear` behavior more intuitive especially when dealing switching between turning the camera on and off. This now means switching between values `auto` and `off` instead of `rear` and `off`. BREAKING CHANGE: `rear` option for camera prop now force requests rear camera. New `auto` option now implements old `rear` behavior.
1 parent cdb646c commit 51540f7

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/components/QrcodeStream.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
class="pause-frame"
1717
></canvas>
1818

19-
<canvas
20-
ref="trackingLayer"
21-
class="tracking-layer"
22-
></canvas>
19+
<canvas ref="trackingLayer" class="tracking-layer"></canvas>
2320

2421
<div class="overlay">
2522
<slot></slot>
@@ -40,10 +37,10 @@ export default {
4037
props: {
4138
camera: {
4239
type: String,
43-
default: "rear",
40+
default: "auto",
4441
4542
validator(camera) {
46-
return ["rear", "front", "off"].includes(camera);
43+
return ["auto", "rear", "front", "off"].includes(camera);
4744
}
4845
},
4946
@@ -102,9 +99,13 @@ export default {
10299
};
103100
104101
switch (this.camera) {
105-
case "rear":
102+
case "auto":
106103
base.video.facingMode = { ideal: "environment" };
107104
105+
return base;
106+
case "rear":
107+
base.video.facingMode = { exact: "environment" };
108+
108109
return base;
109110
case "front":
110111
base.video.facingMode = { exact: "user" };

0 commit comments

Comments
 (0)