@@ -84,8 +84,12 @@ export class MgtFlyout extends LitElement {
8484 // if the flyout is opened once, this will keep the flyout in the dom
8585 private _renderedOnce = false ;
8686
87- @query ( '.flyout' ) private _flyout : HTMLElement ;
88- @query ( '.anchor' ) private _anchor : HTMLElement ;
87+ private get _flyout ( ) : HTMLElement {
88+ return this . renderRoot . querySelector ( '.flyout' ) ;
89+ }
90+ private get _anchor ( ) : HTMLElement {
91+ return this . renderRoot . querySelector ( '.anchor' ) ;
92+ }
8993
9094 private _isOpen : boolean ;
9195
@@ -261,14 +265,14 @@ export class MgtFlyout extends LitElement {
261265 // center in between
262266 left = ( windowRect . width - flyoutRect . width ) / 2 ;
263267 }
264- } else if ( anchorRect . x + flyoutRect . width + this . _edgePadding > windowRect . width ) {
268+ } else if ( anchorRect . left + flyoutRect . width + this . _edgePadding > windowRect . width ) {
265269 // it will render off screen to the right, move to the left
266- left = anchorRect . x - ( anchorRect . x + flyoutRect . width + this . _edgePadding - windowRect . width ) ;
267- } else if ( anchorRect . x < this . _edgePadding ) {
270+ left = anchorRect . left - ( anchorRect . left + flyoutRect . width + this . _edgePadding - windowRect . width ) ;
271+ } else if ( anchorRect . left < this . _edgePadding ) {
268272 // it will render off screen to the left, move to the right
269273 left = this . _edgePadding ;
270274 } else {
271- left = anchorRect . x ;
275+ left = anchorRect . left ;
272276 }
273277
274278 if ( flyoutRect . height + 2 * this . _edgePadding > windowRect . height ) {
@@ -279,20 +283,20 @@ export class MgtFlyout extends LitElement {
279283 top = ( windowRect . height - flyoutRect . height ) / 2 ;
280284 }
281285 } else if (
282- anchorRect . y + anchorRect . height + flyoutRect . height + this . _edgePadding > windowRect . height &&
283- anchorRect . y - flyoutRect . height - this . _edgePadding > 0
286+ anchorRect . top + anchorRect . height + flyoutRect . height + this . _edgePadding > windowRect . height &&
287+ anchorRect . top - flyoutRect . height - this . _edgePadding > 0
284288 ) {
285- if ( windowRect . height - anchorRect . y + flyoutRect . height < 0 ) {
289+ if ( windowRect . height - anchorRect . top + flyoutRect . height < 0 ) {
286290 bottom = windowRect . height - flyoutRect . height - this . _edgePadding ;
287291 } else {
288- bottom = Math . max ( windowRect . height - anchorRect . y , this . _edgePadding ) ;
292+ bottom = Math . max ( windowRect . height - anchorRect . top , this . _edgePadding ) ;
289293 }
290294 } else {
291- if ( anchorRect . y + anchorRect . height + flyoutRect . height + this . _edgePadding > windowRect . height ) {
295+ if ( anchorRect . top + anchorRect . height + flyoutRect . height + this . _edgePadding > windowRect . height ) {
292296 // it will render offscreen bellow, move it up a bit
293297 top = windowRect . height - flyoutRect . height - this . _edgePadding ;
294298 } else {
295- top = Math . max ( anchorRect . y + anchorRect . height , this . _edgePadding ) ;
299+ top = Math . max ( anchorRect . top + anchorRect . height , this . _edgePadding ) ;
296300 }
297301 }
298302
0 commit comments