Skip to content

Commit 56f3497

Browse files
committed
add comment about the ScrollableViewProperties
1 parent 694d3d6 commit 56f3497

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
@@ -126,8 +126,9 @@ export class ConnectedPositionStrategy implements PositionStrategy {
126126
}
127127

128128
/**
129-
* Sets the list of scrolling or resizing containers that host the connectedTo element so that
130-
* on reposition we can evaluate if it has been clipped when repositioned.
129+
* Sets the list of Scrollable containers that host the origin element so that
130+
* on reposition we can evaluate if it or the overlay has been clipped or outside view. Every
131+
* Scrollable must be an ancestor element of the strategy's origin element.
131132
*/
132133
withScrollableContainers(scrollables: Scrollable[]) {
133134
this.scrollables = scrollables;
@@ -271,15 +272,15 @@ export class ConnectedPositionStrategy implements PositionStrategy {
271272
* or completely outside the view of any of the strategy's scrollables.
272273
*/
273274
private getScrollableViewProperties(overlay: HTMLElement): ScrollableViewProperties {
274-
const triggerBounds = this._getElementBounds(this._connectedTo.nativeElement);
275+
const originBounds = this._getElementBounds(this._origin);
275276
const overlayBounds = this._getElementBounds(overlay);
276277
const scrollContainerBounds = this.scrollables.map((scrollable: Scrollable) => {
277278
return this._getElementBounds(scrollable.getElementRef().nativeElement);
278279
});
279280

280281
return {
281-
isTriggerClipped: this.isElementClipped(triggerBounds, scrollContainerBounds),
282-
isTriggerOutsideView: this.isElementOutsideView(triggerBounds, scrollContainerBounds),
282+
isOriginClipped: this.isElementClipped(originBounds, scrollContainerBounds),
283+
isOriginOutsideView: this.isElementOutsideView(originBounds, scrollContainerBounds),
283284
isOverlayClipped: this.isElementClipped(overlayBounds, scrollContainerBounds),
284285
isOverlayOutsideView: this.isElementOutsideView(overlayBounds, scrollContainerBounds),
285286
};

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)