Skip to content

Commit 5f3ab39

Browse files
committed
fix: mobile layout for result
1 parent 0ac0e1c commit 5f3ab39

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
@@ -291,6 +291,7 @@ img {
291291
}
292292

293293
.result-container .scanned-image {
294+
flex: 1;
294295
max-height: 200px;
295296
}
296297

@@ -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;
@@ -562,7 +564,7 @@ img {
562564
}
563565

564566
/* Media query for mobile phones */
565-
@media screen and (orientation: landscape) and (max-width: 1500px) {
567+
@media screen and (orientation: landscape) and (max-width: 900px) {
566568
.result-container .parsed-result-area .parsed-filed {
567569
font-size: 14px;
568570
}

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
@@ -124,6 +124,7 @@ let init = (async () => {
124124
})();
125125

126126
const displayResults = (recognizedText, parsedResult) => {
127+
changeMobileLayout(); // Update mobile layout to support horizontal view
127128
parsedResultArea.innerText = "";
128129

129130
// 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)