Skip to content

Commit aff11c8

Browse files
committed
fix: mobile layout for result
1 parent c6189c6 commit aff11c8

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

css/index.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ img {
290290
}
291291

292292
.result-container .scanned-image {
293+
flex: 1;
293294
max-height: 200px;
294295
}
295296

@@ -301,6 +302,7 @@ img {
301302
}
302303

303304
.result-container .parsed-result-area {
305+
flex: 1;
304306
width: 100%;
305307
height: 84%;
306308
padding: 15px 15px 5px 30px;
@@ -585,7 +587,7 @@ img {
585587
}
586588

587589
/* Media query for mobile phones */
588-
@media screen and (orientation: landscape) and (max-width: 1500px) {
590+
@media screen and (orientation: landscape) and (max-width: 900px) {
589591
.result-container .parsed-result-area .parsed-filed {
590592
font-size: 14px;
591593
}

js/init.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { judgeCurResolution, showNotification } from "./util.js";
1+
import { changeMobileLayout, judgeCurResolution, showNotification } from "./util.js";
22
import { createPendingPromise, extractDocumentFields, resultToHTMLElement } from "./util.js";
33

44
// Promise variable used to control model loading state
@@ -137,6 +137,7 @@ export const handleCapturedResult = (result, uploadedImage = null) => {
137137
};
138138

139139
const displayResults = (recognizedText, parsedResult) => {
140+
changeMobileLayout(); // Update mobile layout to support horizontal view
140141
parsedResultArea.innerText = "";
141142

142143
// Display MRZ text

js/util.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,26 @@ export function shouldShowScanModeContainer() {
213213
scanModeContainer.style.display = isHomepageClosed && isResultClosed ? "flex" : "none";
214214
}
215215

216+
export const isMobile = () =>
217+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
218+
219+
export function changeMobileLayout() {
220+
const resultArea = resultContainer.querySelector(".result-area");
221+
console.log(isMobile(), checkOrientation() === "landscape");
222+
Object.assign(
223+
resultArea.style,
224+
isMobile() && checkOrientation() === "landscape"
225+
? {
226+
height: "70%",
227+
flexDirection: "row",
228+
}
229+
: {
230+
height: "84%",
231+
flexDirection: "column",
232+
}
233+
);
234+
}
235+
216236
/** Show notification banner to users
217237
* @params {string} message - noficiation message
218238
* @params {string} className - CSS class name to show notification status

0 commit comments

Comments
 (0)