@@ -802,7 +802,7 @@ let renderOnce = function() {
802802 dom . attr ( '#firewall [title][data-src]' , 'title' , null ) ;
803803 }
804804
805- // This must be done the firewall is populated
805+ // This must be done when the firewall is populated
806806 if ( popupData . popupPanelHeightMode === 1 ) {
807807 dom . cl . add ( dom . body , 'vMin' ) ;
808808 }
@@ -1462,6 +1462,31 @@ const getPopupData = async function(tabId, first = false) {
14621462 }
14631463 } ;
14641464
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+
14651490 // The purpose of the following code is to reset to a vertical layout
14661491 // should the viewport not be enough wide to accommodate the horizontal
14671492 // layout.
@@ -1474,24 +1499,7 @@ const getPopupData = async function(tabId, first = false) {
14741499 // Use a tolerance proportional to the sum of the width of the panes
14751500 // when testing against viewport width.
14761501 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 ( ) ;
14951503 if ( dom . cl . has ( dom . root , 'portrait' ) ) {
14961504 const panes = qs$ ( '#panes' ) ;
14971505 const sticky = qs$ ( '#sticky' ) ;
0 commit comments