@@ -61,14 +61,18 @@ <h1 style="font-size: 1.5em;">Enlarge the Video Stream</h1>
6161 backToNormal . addEventListener ( 'click' , ( ) => {
6262 exitFullPage ( ) ;
6363 } ) ;
64- fitPage . addEventListener ( 'click' , ( ) => {
64+ fitPage . addEventListener ( 'click' , async ( ) => {
65+ fitPage . hidden = true ;
6566 UIElement . classList . add ( "fullscreen" ) ;
67+ await updateDisplayArea ( ) ;
6668 backToNormal . hidden = false ;
6769 } ) ;
6870
69- function exitFullPage ( ) {
70- UIElement . classList . remove ( "fullscreen" ) ;
71+ async function exitFullPage ( ) {
7172 backToNormal . hidden = true ;
73+ UIElement . classList . remove ( "fullscreen" ) ;
74+ await updateDisplayArea ( ) ;
75+ fitPage . hidden = false ;
7276 }
7377 // decode video from camera
7478 async function showScanner ( ) {
@@ -77,7 +81,8 @@ <h1 style="font-size: 1.5em;">Enlarge the Video Stream</h1>
7781 await scanner . setUIElement ( document . getElementById ( 'div-ui-container' ) ) ;
7882 scanner . onUniqueRead = ( txt , result ) => {
7983 document . getElementById ( 'result' ) . value = result . barcodeFormatString + ": " + txt ;
80- exitFullPage ( ) ;
84+ if ( fitPage . hidden )
85+ exitFullPage ( ) ;
8186 document . getElementById ( 'result' ) . focus ( ) ;
8287 setTimeout ( ( ) => {
8388 document . getElementById ( 'result' ) . blur ( ) ;
@@ -92,6 +97,12 @@ <h1 style="font-size: 1.5em;">Enlarge the Video Stream</h1>
9297 throw ex ;
9398 }
9499 }
100+ async function updateDisplayArea ( ) {
101+ let scanner = await pScanner ;
102+ // trigger the resize event to adjust the positioning of the code area
103+ const resizeEvent = new Event ( 'resize' ) ;
104+ window . dispatchEvent ( resizeEvent ) ;
105+ }
95106 </ script >
96107</ body >
97108< style >
0 commit comments