Skip to content

Commit 15e6791

Browse files
committed
Move desktop detection to _isPortrait helper function.
1 parent e98af38 commit 15e6791

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

components/BarcodeScanner.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,9 @@ export default {
7878
const aspectRatio = computed(() => {
7979
const width = window.innerWidth;
8080
const height = window.innerHeight;
81-
const isDesktop = !$q.platform.is.desktop;
8281
// must parse float aspect ratio value
8382
return parseFloat(
84-
// format aspectRatio to landscape for desktop
85-
_isPortrait() && !isDesktop ?
86-
height / width : width / height).toFixed(3);
83+
_isPortrait() ? height / width : width / height).toFixed(3);
8784
});
8885
8986
// Lifecycle hooks
@@ -279,8 +276,10 @@ export default {
279276
);
280277
}
281278
279+
// desktop is never considered for portrait mode
282280
function _isPortrait() {
283-
return window.matchMedia('(orientation: portrait)').matches;
281+
const isDesktop = $q.platform.is.desktop;
282+
return window.matchMedia('(orientation: portrait)').matches && !isDesktop;
284283
}
285284
286285
return {

0 commit comments

Comments
 (0)