UNPKG

3.1 kBTypeScriptView Raw
1import { PositionStrategy } from './position-strategy';
2import { ElementRef } from '@angular/core';
3import { ViewportRuler } from './viewport-ruler';
4import { ConnectionPositionPair, OriginConnectionPosition, OverlayConnectionPosition } from './connected-position';
5/**
6 * A strategy for positioning overlays. Using this strategy, an overlay is given an
7 * implict position relative some origin element. The relative position is defined in terms of
8 * a point on the origin element that is connected to a point on the overlay element. For example,
9 * a basic dropdown is connecting the bottom-left corner of the origin to the top-left corner
10 * of the overlay.
11 */
12export declare class ConnectedPositionStrategy implements PositionStrategy {
13 private _connectedTo;
14 private _originPos;
15 private _overlayPos;
16 private _viewportRuler;
17 /** Whether the we're dealing with an RTL context */
18 _isRtl: boolean;
19 /** Ordered list of preferred positions, from most to least desirable. */
20 _preferredPositions: ConnectionPositionPair[];
21 /** The origin element against which the overlay will be positioned. */
22 private _origin;
23 constructor(_connectedTo: ElementRef, _originPos: OriginConnectionPosition, _overlayPos: OverlayConnectionPosition, _viewportRuler: ViewportRuler);
24 readonly positions: ConnectionPositionPair[];
25 /**
26 * Updates the position of the overlay element, using whichever preferred position relative
27 * to the origin fits on-screen.
28 * TODO: internal
29 */
30 apply(element: HTMLElement): Promise<void>;
31 withFallbackPosition(originPos: OriginConnectionPosition, overlayPos: OverlayConnectionPosition): this;
32 /**
33 * Gets the horizontal (x) "start" dimension based on whether the overlay is in an RTL context.
34 * @param rect
35 */
36 private _getStartX(rect);
37 /**
38 * Gets the horizontal (x) "end" dimension based on whether the overlay is in an RTL context.
39 * @param rect
40 */
41 private _getEndX(rect);
42 /**
43 * Gets the (x, y) coordinate of a connection point on the origin based on a relative position.
44 * @param originRect
45 * @param pos
46 */
47 private _getOriginConnectionPoint(originRect, pos);
48 /**
49 * Gets the (x, y) coordinate of the top-left corner of the overlay given a given position and
50 * origin point to which the overlay should be connected.
51 * @param originPoint
52 * @param overlayRect
53 * @param pos
54 */
55 private _getOverlayPoint(originPoint, overlayRect, pos);
56 /**
57 * Gets whether the overlay positioned at the given point will fit on-screen.
58 * @param overlayPoint The top-left coordinate of the overlay.
59 * @param overlayRect Bounding rect of the overlay, used to get its size.
60 * @param viewportRect The bounding viewport.
61 */
62 private _willOverlayFitWithinViewport(overlayPoint, overlayRect, viewportRect);
63 /**
64 * Physically positions the overlay element to the given coordinate.
65 * @param element
66 * @param overlayPoint
67 */
68 private _setElementPosition(element, overlayPoint);
69}