@@ -41,8 +41,11 @@ export type FlexibleConnectedPositionStrategyOrigin =
4141 height ?: number ;
4242 } ) ;
4343
44- /** Equivalent of `DOMRect` without some of the properties we don't care about. */
45- type Dimensions = Omit < DOMRect , 'x' | 'y' | 'toJSON' > ;
44+ /** Refinment of `DOMRect` when only width/height and position (l, r, t, b) are needed. */
45+ type Rect = Omit < DOMRect , 'x' | 'y' | 'toJSON' > ;
46+
47+ /** Further refinement of above for when only the dimensions are needed. */
48+ type Dimensions = Omit < Rect , 'left' | 'top' | 'right' | 'bottom' > ;
4649
4750/**
4851 * Creates a flexible position strategy.
@@ -94,17 +97,17 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
9497 /** Whether the overlay position is locked. */
9598 private _positionLocked = false ;
9699
97- /** Cached origin dimensions */
98- private _originRect : Dimensions ;
100+ /** Cached origin placement and dimentsions. */
101+ private _originRect : Rect ;
99102
100- /** Cached overlay dimensions */
101- private _overlayRect : Dimensions ;
103+ /** Cached overlay placement and dimensions */
104+ private _overlayRect : Rect ;
102105
103- /** Cached viewport dimensions */
104- private _viewportRect : Dimensions ;
106+ /** Cached viewport placement and dimensions */
107+ private _viewportRect : Rect ;
105108
106- /** Cached container dimensions */
107- private _containerRect : Dimensions ;
109+ /** Cached container placement and dimensions */
110+ private _containerRect : Rect ;
108111
109112 /** Amount of space that must be maintained between the overlay and the edge of the viewport. */
110113 private _viewportMargin = 0 ;
@@ -512,11 +515,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
512515 /**
513516 * Gets the (x, y) coordinate of a connection point on the origin based on a relative position.
514517 */
515- private _getOriginPoint (
516- originRect : Dimensions ,
517- containerRect : Dimensions ,
518- pos : ConnectedPosition ,
519- ) : Point {
518+ private _getOriginPoint ( originRect : Rect , containerRect : Rect , pos : ConnectedPosition ) : Point {
520519 let x : number ;
521520 if ( pos . originX == 'center' ) {
522521 // Note: when centering we should always use the `left`
@@ -590,7 +589,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
590589 /** Gets how well an overlay at the given point will fit within the viewport. */
591590 private _getOverlayFit (
592591 point : Point ,
593- rawOverlayRect : Dimensions ,
592+ rawOverlayRect : Rect ,
594593 viewport : Dimensions ,
595594 position : ConnectedPosition ,
596595 ) : OverlayFit {
@@ -635,7 +634,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
635634 * @param point The (x, y) coordinates of the overlay at some position.
636635 * @param viewport The geometry of the viewport.
637636 */
638- private _canFitWithFlexibleDimensions ( fit : OverlayFit , point : Point , viewport : Dimensions ) {
637+ private _canFitWithFlexibleDimensions ( fit : OverlayFit , point : Point , viewport : Rect ) {
639638 if ( this . _hasFlexibleDimensions ) {
640639 const availableHeight = viewport . bottom - point . y ;
641640 const availableWidth = viewport . right - point . x ;
@@ -665,7 +664,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
665664 */
666665 private _pushOverlayOnScreen (
667666 start : Point ,
668- rawOverlayRect : Dimensions ,
667+ rawOverlayRect : Rect ,
669668 scrollPosition : ViewportScrollPosition ,
670669 ) : Point {
671670 // If the position is locked and we've pushed the overlay already, reuse the previous push
@@ -1105,7 +1104,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
11051104 }
11061105
11071106 /** Narrows the given viewport rect by the current _viewportMargin. */
1108- private _getNarrowedViewportRect ( ) : Dimensions {
1107+ private _getNarrowedViewportRect ( ) : Rect {
11091108 // We recalculate the viewport rect here ourselves, rather than using the ViewportRuler,
11101109 // because we want to use the `clientWidth` and `clientHeight` as the base. The difference
11111110 // being that the client properties don't include the scrollbar, as opposed to `innerWidth`
@@ -1187,7 +1186,7 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
11871186 }
11881187
11891188 /** Returns the DOMRect of the current origin. */
1190- private _getOriginRect ( ) : Dimensions {
1189+ private _getOriginRect ( ) : Rect {
11911190 const origin = this . _origin ;
11921191
11931192 if ( origin instanceof ElementRef ) {
@@ -1309,7 +1308,7 @@ function getPixelValue(input: number | string | null | undefined): number | null
13091308 * deviations in the `DOMRect` returned by the browser (e.g. when zoomed in with a percentage
13101309 * size, see #21350).
13111310 */
1312- function getRoundedBoundingClientRect ( clientRect : Dimensions ) : Dimensions {
1311+ function getRoundedBoundingClientRect ( clientRect : Rect ) : Rect {
13131312 return {
13141313 top : Math . floor ( clientRect . top ) ,
13151314 right : Math . floor ( clientRect . right ) ,
0 commit comments