dad3f04e8292b8087adb3205cdc20385ef6752e3
[sdc/sdc-workflow-designer.git] /
1 /**
2  * @license
3  * Copyright Google Inc. All Rights Reserved.
4  *
5  * Use of this source code is governed by an MIT-style license that can be
6  * found in the LICENSE file at https://angular.io/license
7  */
8 /* tslint:disable:array-type member-access variable-name typedef
9  only-arrow-functions directive-class-suffix component-class-suffix
10  component-selector no-unnecessary-type-assertion arrow-parens*/
11 /** Horizontal dimension of a connection point on the perimeter of the origin or
12  * overlay element. */
13 import {Optional} from '@angular/core';
14 export type HorizontalConnectionPos = 'start' | 'center' | 'end';
15
16 /** Vertical dimension of a connection point on the perimeter of the origin or
17  * overlay element. */
18 export type VerticalConnectionPos = 'top' | 'center' | 'bottom';
19
20
21 /** A connection point on the origin element. */
22 export interface OriginConnectionPosition {
23   originX: HorizontalConnectionPos;
24   originY: VerticalConnectionPos;
25 }
26
27 /** A connection point on the overlay element. */
28 export interface OverlayConnectionPosition {
29   overlayX: HorizontalConnectionPos;
30   overlayY: VerticalConnectionPos;
31 }
32
33 /** The points of the origin element and the overlay element to connect. */
34 export class ConnectionPositionPair {
35   originX: HorizontalConnectionPos;
36   originY: VerticalConnectionPos;
37   overlayX: HorizontalConnectionPos;
38   overlayY: VerticalConnectionPos;
39
40   constructor(
41                 origin: OriginConnectionPosition, overlay: OverlayConnectionPosition) {
42         this.originX = origin.originX;
43         this.originY = origin.originY;
44         this.overlayX = overlay.overlayX;
45         this.overlayY = overlay.overlayY;
46   }
47 }
48
49 /**
50  * Set of properties regarding the position of the origin and overlay relative
51  * to the viewport with respect to the containing Scrollable elements.
52  *
53  * The overlay and origin are clipped if any part of their bounding client
54  * rectangle exceeds the bounds of any one of the strategy's Scrollable's
55  * bounding client rectangle.
56  *
57  * The overlay and origin are outside view if there is no overlap between their
58  * bounding client rectangle and any one of the strategy's Scrollable's bounding
59  * client rectangle.
60  *
61  *       -----------                    -----------
62  *       | outside |                    | clipped |
63  *       |  view   |              --------------------------
64  *       |         |              |     |         |        |
65  *       ----------               |     -----------        |
66  *  --------------------------    |                        |
67  *  |                        |    |      Scrollable        |
68  *  |                        |    |                        |
69  *  |                        |     --------------------------
70  *  |      Scrollable        |
71  *  |                        |
72  *  --------------------------
73  */
74 export class ScrollableViewProperties {
75   isOriginClipped: boolean;
76   isOriginOutsideView: boolean;
77   isOverlayClipped: boolean;
78   isOverlayOutsideView: boolean;
79 }
80
81 /** The change event emitted by the strategy when a fallback position is used.
82  */
83 export class ConnectedOverlayPositionChange {
84   constructor(
85                 public connectionPair: ConnectionPositionPair,
86                 @Optional() public scrollableViewProperties: ScrollableViewProperties) {}
87 }