Skip to content

Commit 5c906ed

Browse files
committed
add comment about the ScrollableViewProperties
1 parent ac6c7ee commit 5c906ed

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

src/lib/core/overlay/position/connected-position-strategy.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ export class ConnectedPositionStrategy implements PositionStrategy {
122122
}
123123

124124
/**
125-
* Sets the list of scrolling or resizing containers that host the connectedTo element so that
126-
* on reposition we can evaluate if it has been clipped when repositioned.
125+
* Sets the list of Scrollable containers that host the origin element so that
126+
* on reposition we can evaluate if it or the overlay has been clipped or outside view. Every
127+
* Scrollable must be an ancestor element of the strategy's origin element.
127128
*/
128129
withScrollableContainers(scrollables: Scrollable[]) {
129130
this.scrollables = scrollables;
@@ -252,15 +253,15 @@ export class ConnectedPositionStrategy implements PositionStrategy {
252253
* or completely outside the view of any of the strategy's scrollables.
253254
*/
254255
private getScrollableViewProperties(overlay: HTMLElement): ScrollableViewProperties {
255-
const triggerBounds = this._getElementBounds(this._connectedTo.nativeElement);
256+
const originBounds = this._getElementBounds(this._origin);
256257
const overlayBounds = this._getElementBounds(overlay);
257258
const scrollContainerBounds = this.scrollables.map((scrollable: Scrollable) => {
258259
return this._getElementBounds(scrollable.getElementRef().nativeElement);
259260
});
260261

261262
return {
262-
isTriggerClipped: this.isElementClipped(triggerBounds, scrollContainerBounds),
263-
isTriggerOutsideView: this.isElementOutsideView(triggerBounds, scrollContainerBounds),
263+
isOriginClipped: this.isElementClipped(originBounds, scrollContainerBounds),
264+
isOriginOutsideView: this.isElementOutsideView(originBounds, scrollContainerBounds),
264265
isOverlayClipped: this.isElementClipped(overlayBounds, scrollContainerBounds),
265266
isOverlayOutsideView: this.isElementOutsideView(overlayBounds, scrollContainerBounds),
266267
};

src/lib/core/overlay/position/connected-position.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,32 @@ export class ConnectionPositionPair {
3333
}
3434
}
3535

36+
/**
37+
* Set of properties regarding the position of the origin and overlay relative to the viewport
38+
* with respect to the containing Scrollable elements.
39+
*
40+
* The overlay and origin are clipped if any part of their bounding client rectangle exceeds the
41+
* bounds of any one of the strategy's Scrollable's bounding client rectangle.
42+
*
43+
* The overlay and origin are outside view if there is no overlap between their bounding client
44+
* rectangle and any one of the strategy's Scrollable's bounding client rectangle.
45+
*
46+
* ----------- -----------
47+
* | outside | | clipped |
48+
* | view | --------------------------
49+
* | | | | | |
50+
* ---------- | ----------- |
51+
* -------------------------- | |
52+
* | | | Scrollable |
53+
* | | | |
54+
* | | --------------------------
55+
* | Scrollable |
56+
* | |
57+
* --------------------------
58+
*/
3659
export class ScrollableViewProperties {
37-
isTriggerClipped: boolean;
38-
isTriggerOutsideView: boolean;
60+
isOriginClipped: boolean;
61+
isOriginOutsideView: boolean;
3962
isOverlayClipped: boolean;
4063
isOverlayOutsideView: boolean;
4164
}

0 commit comments

Comments
 (0)