@@ -802,7 +802,7 @@ let renderOnce = function() {
802
802
dom . attr ( '#firewall [title][data-src]' , 'title' , null ) ;
803
803
}
804
804
805
- // This must be done the firewall is populated
805
+ // This must be done when the firewall is populated
806
806
if ( popupData . popupPanelHeightMode === 1 ) {
807
807
dom . cl . add ( dom . body , 'vMin' ) ;
808
808
}
@@ -1462,6 +1462,31 @@ const getPopupData = async function(tabId, first = false) {
1462
1462
}
1463
1463
} ;
1464
1464
1465
+ const setOrientation = async ( ) => {
1466
+ if ( dom . cl . has ( dom . root , 'mobile' ) ) {
1467
+ dom . cl . remove ( dom . root , 'desktop' ) ;
1468
+ dom . cl . add ( dom . root , 'portrait' ) ;
1469
+ return ;
1470
+ }
1471
+ if ( selfURL . searchParams . get ( 'portrait' ) !== null ) {
1472
+ dom . cl . add ( dom . root , 'portrait' ) ;
1473
+ return ;
1474
+ }
1475
+ if ( popupData . popupPanelOrientation === 'landscape' ) { return ; }
1476
+ if ( popupData . popupPanelOrientation === 'portrait' ) {
1477
+ dom . cl . add ( dom . root , 'portrait' ) ;
1478
+ return ;
1479
+ }
1480
+ if ( dom . cl . has ( dom . root , 'desktop' ) === false ) { return ; }
1481
+ await nextFrames ( 8 ) ;
1482
+ const main = qs$ ( '#main' ) ;
1483
+ const firewall = qs$ ( '#firewall' ) ;
1484
+ const minWidth = ( main . offsetWidth + firewall . offsetWidth ) / 1.1 ;
1485
+ if ( window . innerWidth < minWidth ) {
1486
+ dom . cl . add ( dom . root , 'portrait' ) ;
1487
+ }
1488
+ } ;
1489
+
1465
1490
// The purpose of the following code is to reset to a vertical layout
1466
1491
// should the viewport not be enough wide to accommodate the horizontal
1467
1492
// layout.
@@ -1474,24 +1499,7 @@ const getPopupData = async function(tabId, first = false) {
1474
1499
// Use a tolerance proportional to the sum of the width of the panes
1475
1500
// when testing against viewport width.
1476
1501
const checkViewport = async function ( ) {
1477
- if (
1478
- dom . cl . has ( dom . root , 'mobile' ) ||
1479
- selfURL . searchParams . get ( 'portrait' )
1480
- ) {
1481
- dom . cl . add ( dom . root , 'portrait' ) ;
1482
- dom . cl . remove ( dom . root , 'desktop' ) ;
1483
- } else if ( dom . cl . has ( dom . root , 'desktop' ) ) {
1484
- await nextFrames ( 8 ) ;
1485
- const main = qs$ ( '#main' ) ;
1486
- const firewall = qs$ ( '#firewall' ) ;
1487
- const minWidth = ( main . offsetWidth + firewall . offsetWidth ) / 1.1 ;
1488
- if (
1489
- selfURL . searchParams . get ( 'portrait' ) ||
1490
- window . innerWidth < minWidth
1491
- ) {
1492
- dom . cl . add ( dom . root , 'portrait' ) ;
1493
- }
1494
- }
1502
+ await setOrientation ( ) ;
1495
1503
if ( dom . cl . has ( dom . root , 'portrait' ) ) {
1496
1504
const panes = qs$ ( '#panes' ) ;
1497
1505
const sticky = qs$ ( '#sticky' ) ;
0 commit comments