@@ -115,20 +115,27 @@ export class PopoverTransition extends PageTransition {
115
115
// If the popover left is less than the padding it is off screen
116
116
// to the left so adjust it, else if the width of the popover
117
117
// exceeds the body width it is off screen to the right so adjust
118
- if ( popoverCSS . left < POPOVER_IOS_BODY_PADDING ) {
118
+ //
119
+ let checkSafeAreaLeft = false ;
120
+ let checkSafeAreaRight = false ;
121
+
122
+ // If the popover left is less than the padding it is off screen
123
+ // to the left so adjust it, else if the width of the popover
124
+ // exceeds the body width it is off screen to the right so adjust
125
+ // 25 is a random/arbitrary number. It seems to work fine for ios11
126
+ // and iPhoneX. Is it perfect? No. Does it work? Yes.
127
+ if ( popoverCSS . left < ( POPOVER_IOS_BODY_PADDING + 25 ) ) {
128
+ checkSafeAreaLeft = true ;
119
129
popoverCSS . left = POPOVER_IOS_BODY_PADDING ;
120
- } else if ( popoverWidth + POPOVER_IOS_BODY_PADDING + popoverCSS . left > bodyWidth ) {
121
- if ( CSS . supports ( 'left' , 'constant(safe-area-inset-left)' ) ) {
122
- popoverCSS . left = `calc(${ bodyWidth - popoverWidth - POPOVER_IOS_BODY_PADDING } px - constant(safe-area-inset-left)` ;
123
- } else if ( CSS . supports ( 'left' , 'env(safe-area-inset-left)' ) ) {
124
- popoverCSS . left = `calc(${ bodyWidth - popoverWidth - POPOVER_IOS_BODY_PADDING } px - env(safe-area-inset-left)` ;
125
- } else {
126
- popoverCSS . left = `${ bodyWidth - popoverWidth - POPOVER_IOS_BODY_PADDING } px` ;
127
- }
130
+ } else if ( ( popoverWidth + POPOVER_IOS_BODY_PADDING + popoverCSS . left + 25 ) > bodyWidth ) {
131
+ // Ok, so we're on the right side of the screen,
132
+ // but now we need to make sure we're still a bit further right
133
+ // cus....notchurally... Again, 25 is random. It works tho
134
+ checkSafeAreaRight = true ;
135
+ popoverCSS . left = bodyWidth - popoverWidth - POPOVER_IOS_BODY_PADDING ;
128
136
originX = 'right' ;
129
137
}
130
138
131
- // If the popover when popped down stretches past bottom of screen,
132
139
// make it pop up if there's room above
133
140
if ( targetTop + targetHeight + popoverHeight > bodyHeight && targetTop - popoverHeight > 0 ) {
134
141
arrowCSS . top = targetTop - ( arrowHeight + 1 ) ;
@@ -144,7 +151,25 @@ export class PopoverTransition extends PageTransition {
144
151
arrowEle . style . left = arrowCSS . left + 'px' ;
145
152
146
153
popoverEle . style . top = popoverCSS . top + 'px' ;
147
- popoverEle . style . left = popoverCSS . left ;
154
+ popoverEle . style . left = popoverCSS . left + 'px' ;
155
+
156
+ if ( checkSafeAreaLeft ) {
157
+ if ( CSS . supports ( 'left' , 'constant(safe-area-inset-left)' ) ) {
158
+ popoverEle . style . left = `calc(${ popoverCSS . left } px + constant(safe-area-inset-left)` ;
159
+
160
+ } else if ( CSS . supports ( 'left' , 'env(safe-area-inset-left)' ) ) {
161
+ popoverEle . style . left = `calc(${ popoverCSS . left } px + env(safe-area-inset-left)` ;
162
+ }
163
+ }
164
+
165
+ if ( checkSafeAreaRight ) {
166
+ if ( CSS . supports ( 'right' , 'constant(safe-area-inset-right)' ) ) {
167
+ popoverEle . style . left = `calc(${ popoverCSS . left } px - constant(safe-area-inset-right)` ;
168
+ } else if ( CSS . supports ( 'right' , 'env(safe-area-inset-right)' ) ) {
169
+ popoverEle . style . left = `calc(${ popoverCSS . left } px - env(safe-area-inset-right)` ;
170
+ }
171
+ }
172
+
148
173
149
174
( < any > popoverEle . style ) [ this . plt . Css . transformOrigin ] = originY + ' ' + originX ;
150
175
0 commit comments