@@ -564,30 +564,48 @@ export class Platform {
564
564
// we're not forcing many layouts
565
565
// if _isPortrait is null then that means
566
566
// the dimensions needs to be looked up again
567
- if ( this . _isPortrait === null ) {
567
+ // this also has to cover an edge case that only
568
+ // happens on iOS 10 (not other versions of iOS)
569
+ // where window.innerWidth is always bigger than
570
+ // window.innerHeight when it is first measured,
571
+ // even when the device is in portrait but
572
+ // the second time it is measured it is correct.
573
+ // Hopefully this check will not be needed in the future
574
+ if ( this . _isPortrait === null || this . _isPortrait === false && this . _win [ 'innerWidth' ] < this . _win [ 'innerHeight' ] ) {
568
575
var win = this . _win ;
569
576
570
577
// we're keeping track of portrait and landscape dimensions
571
578
// separately because the virtual keyboard can really mess
572
579
// up accurate values when the keyboard is up
573
580
if ( win . screen . width > 0 && win . screen . height > 0 ) {
574
- if ( win . screen . width < win . screen . height ) {
581
+ if ( win [ 'innerWidth' ] < win [ 'innerHeight' ] ) {
575
582
576
- if ( this . _pW < win [ 'innerWidth' ] ) {
583
+ // the device is in portrait
584
+ if ( this . _pW <= win [ 'innerWidth' ] ) {
585
+ console . debug ( 'setting _isPortrait to true' ) ;
577
586
this . _isPortrait = true ;
578
587
this . _pW = win [ 'innerWidth' ] ;
579
588
}
580
- if ( this . _pH < win [ 'innerHeight' ] ) {
589
+ if ( this . _pH <= win [ 'innerHeight' ] ) {
590
+ console . debug ( 'setting _isPortrait to true' ) ;
581
591
this . _isPortrait = true ;
582
592
this . _pH = win [ 'innerHeight' ] ;
583
593
}
584
594
585
595
} else {
586
- if ( this . _lW < win [ 'innerWidth' ] ) {
596
+ if ( this . _lW > win [ 'innerWidth' ] ) {
597
+ // Special case: keyboard is open and device is in portrait
598
+ console . debug ( 'setting _isPortrait to true while keyboard is open and device is portrait' ) ;
599
+ this . _isPortrait = true ;
600
+ }
601
+ // the device is in landscape
602
+ if ( this . _lW <= win [ 'innerWidth' ] ) {
603
+ console . debug ( 'setting _isPortrait to false' ) ;
587
604
this . _isPortrait = false ;
588
605
this . _lW = win [ 'innerWidth' ] ;
589
606
}
590
- if ( this . _lH < win [ 'innerHeight' ] ) {
607
+ if ( this . _lH <= win [ 'innerHeight' ] ) {
608
+ console . debug ( 'setting _isPortrait to false' ) ;
591
609
this . _isPortrait = false ;
592
610
this . _lH = win [ 'innerHeight' ] ;
593
611
}
@@ -788,7 +806,9 @@ export class Platform {
788
806
timerId = setTimeout ( ( ) => {
789
807
// setting _isPortrait to null means the
790
808
// dimensions will need to be looked up again
791
- this . _isPortrait = null ;
809
+ if ( this . hasFocusedTextInput ( ) === false ) {
810
+ this . _isPortrait = null ;
811
+ }
792
812
793
813
for ( let i = 0 ; i < this . _onResizes . length ; i ++ ) {
794
814
try {
0 commit comments