File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
barcode-scanner-api-samples/scan-multiple-barcodes Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ <h2>Simulated Shopping Cart</h2>
120120 </ div >
121121
122122 < script >
123+ const dragDiv = document . getElementById ( "floatingDiv" ) ;
123124 // Function to initialize and launch the barcode scanner
124125 async function startScanner ( ) {
125126 // Create a new instance of Dynamsoft BarcodeScanner with configuration options
@@ -225,7 +226,6 @@ <h2>Simulated Shopping Cart</h2>
225226 . addEventListener ( "click" , startScanner ) ;
226227
227228 // Make the Floating Div Draggable
228- const dragDiv = document . getElementById ( "floatingDiv" ) ;
229229 let offsetX = 0 ,
230230 offsetY = 0 ,
231231 isDragging = false ;
@@ -252,15 +252,20 @@ <h2>Simulated Shopping Cart</h2>
252252 } ) ;
253253
254254 document . addEventListener ( "touchmove" , ( e ) => {
255- e . preventDefault ( ) ;
256255 if ( isDragging ) {
256+ e . preventDefault ( ) ;
257257 dragDiv . style . left = `${ e . touches [ 0 ] . clientX - offsetX } px` ;
258258 dragDiv . style . top = `${ e . touches [ 0 ] . clientY - offsetY } px` ;
259259 }
260260 } , { passive : false } ) ;
261261
262262 document . addEventListener ( "touchend" , ( ) => ( isDragging = false ) ) ;
263263 } ;
264+
265+ window . addEventListener ( "orientationchange" , ( ) => {
266+ dragDiv . style . left = "10%"
267+ dragDiv . style . top = "40%"
268+ } )
264269 </ script >
265270</ body >
266271
You can’t perform that action at this time.
0 commit comments