@@ -38,6 +38,9 @@ export type FlexibleConnectedPositionStrategyOrigin = ElementRef | Element | Poi
3838 height ?: number ;
3939} ;
4040
41+ /** Equivalent of `ClientRect` without some of the properties we don't care about. */
42+ type Dimensions = Omit < ClientRect , 'x' | 'y' | 'toJSON' > ;
43+
4144/**
4245 * A strategy for positioning overlays. Using this strategy, an overlay is given an
4346 * implicit position relative some origin element. The relative position is defined in terms of
@@ -71,13 +74,13 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
7174 private _positionLocked = false ;
7275
7376 /** Cached origin dimensions */
74- private _originRect : ClientRect ;
77+ private _originRect : Dimensions ;
7578
7679 /** Cached overlay dimensions */
77- private _overlayRect : ClientRect ;
80+ private _overlayRect : Dimensions ;
7881
7982 /** Cached viewport dimensions */
80- private _viewportRect : ClientRect ;
83+ private _viewportRect : Dimensions ;
8184
8285 /** Amount of space that must be maintained between the overlay and the edge of the viewport. */
8386 private _viewportMargin = 0 ;
@@ -467,7 +470,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
467470 /**
468471 * Gets the (x, y) coordinate of a connection point on the origin based on a relative position.
469472 */
470- private _getOriginPoint ( originRect : ClientRect , pos : ConnectedPosition ) : Point {
473+ private _getOriginPoint ( originRect : Dimensions , pos : ConnectedPosition ) : Point {
471474 let x : number ;
472475 if ( pos . originX == 'center' ) {
473476 // Note: when centering we should always use the `left`
@@ -496,7 +499,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
496499 */
497500 private _getOverlayPoint (
498501 originPoint : Point ,
499- overlayRect : ClientRect ,
502+ overlayRect : Dimensions ,
500503 pos : ConnectedPosition ) : Point {
501504
502505 // Calculate the (overlayStartX, overlayStartY), the start of the
@@ -525,7 +528,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
525528 }
526529
527530 /** Gets how well an overlay at the given point will fit within the viewport. */
528- private _getOverlayFit ( point : Point , rawOverlayRect : ClientRect , viewport : ClientRect ,
531+ private _getOverlayFit ( point : Point , rawOverlayRect : Dimensions , viewport : Dimensions ,
529532 position : ConnectedPosition ) : OverlayFit {
530533
531534 // Round the overlay rect when comparing against the
@@ -569,7 +572,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
569572 * @param point The (x, y) coordinates of the overlat at some position.
570573 * @param viewport The geometry of the viewport.
571574 */
572- private _canFitWithFlexibleDimensions ( fit : OverlayFit , point : Point , viewport : ClientRect ) {
575+ private _canFitWithFlexibleDimensions ( fit : OverlayFit , point : Point , viewport : Dimensions ) {
573576 if ( this . _hasFlexibleDimensions ) {
574577 const availableHeight = viewport . bottom - point . y ;
575578 const availableWidth = viewport . right - point . x ;
@@ -598,7 +601,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
598601 * originPoint.
599602 */
600603 private _pushOverlayOnScreen ( start : Point ,
601- rawOverlayRect : ClientRect ,
604+ rawOverlayRect : Dimensions ,
602605 scrollPosition : ViewportScrollPosition ) : Point {
603606 // If the position is locked and we've pushed the overlay already, reuse the previous push
604607 // amount, rather than pushing it again. If we were to continue pushing, the element would
@@ -1029,7 +1032,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
10291032 }
10301033
10311034 /** Narrows the given viewport rect by the current _viewportMargin. */
1032- private _getNarrowedViewportRect ( ) : ClientRect {
1035+ private _getNarrowedViewportRect ( ) : Dimensions {
10331036 // We recalculate the viewport rect here ourselves, rather than using the ViewportRuler,
10341037 // because we want to use the `clientWidth` and `clientHeight` as the base. The difference
10351038 // being that the client properties don't include the scrollbar, as opposed to `innerWidth`
@@ -1111,7 +1114,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
11111114 }
11121115
11131116 /** Returns the ClientRect of the current origin. */
1114- private _getOriginRect ( ) : ClientRect {
1117+ private _getOriginRect ( ) : Dimensions {
11151118 const origin = this . _origin ;
11161119
11171120 if ( origin instanceof ElementRef ) {
@@ -1165,7 +1168,7 @@ interface FallbackPosition {
11651168 originPoint : Point ;
11661169 overlayPoint : Point ;
11671170 overlayFit : OverlayFit ;
1168- overlayRect : ClientRect ;
1171+ overlayRect : Dimensions ;
11691172}
11701173
11711174/** Position and size of the overlay sizing wrapper for a specific position. */
@@ -1182,7 +1185,7 @@ interface BoundingBoxRect {
11821185interface FlexibleFit {
11831186 position : ConnectedPosition ;
11841187 origin : Point ;
1185- overlayRect : ClientRect ;
1188+ overlayRect : Dimensions ;
11861189 boundingBoxRect : BoundingBoxRect ;
11871190}
11881191
@@ -1232,7 +1235,7 @@ function getPixelValue(input: number|string|null|undefined): number|null {
12321235 * deviations in the `ClientRect` returned by the browser (e.g. when zoomed in with a percentage
12331236 * size, see #21350).
12341237 */
1235- function getRoundedBoundingClientRect ( clientRect : ClientRect ) : ClientRect {
1238+ function getRoundedBoundingClientRect ( clientRect : Dimensions ) : Dimensions {
12361239 return {
12371240 top : Math . floor ( clientRect . top ) ,
12381241 right : Math . floor ( clientRect . right ) ,
0 commit comments