1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC 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 | /** Class to be added to the overlay pane wrapper. */
|
---|
9 | const wrapperClass = 'cdk-global-overlay-wrapper';
|
---|
10 | /**
|
---|
11 | * A strategy for positioning overlays. Using this strategy, an overlay is given an
|
---|
12 | * explicit position relative to the browser's viewport. We use flexbox, instead of
|
---|
13 | * transforms, in order to avoid issues with subpixel rendering which can cause the
|
---|
14 | * element to become blurry.
|
---|
15 | */
|
---|
16 | export class GlobalPositionStrategy {
|
---|
17 | constructor() {
|
---|
18 | this._cssPosition = 'static';
|
---|
19 | this._topOffset = '';
|
---|
20 | this._bottomOffset = '';
|
---|
21 | this._leftOffset = '';
|
---|
22 | this._rightOffset = '';
|
---|
23 | this._alignItems = '';
|
---|
24 | this._justifyContent = '';
|
---|
25 | this._width = '';
|
---|
26 | this._height = '';
|
---|
27 | }
|
---|
28 | attach(overlayRef) {
|
---|
29 | const config = overlayRef.getConfig();
|
---|
30 | this._overlayRef = overlayRef;
|
---|
31 | if (this._width && !config.width) {
|
---|
32 | overlayRef.updateSize({ width: this._width });
|
---|
33 | }
|
---|
34 | if (this._height && !config.height) {
|
---|
35 | overlayRef.updateSize({ height: this._height });
|
---|
36 | }
|
---|
37 | overlayRef.hostElement.classList.add(wrapperClass);
|
---|
38 | this._isDisposed = false;
|
---|
39 | }
|
---|
40 | /**
|
---|
41 | * Sets the top position of the overlay. Clears any previously set vertical position.
|
---|
42 | * @param value New top offset.
|
---|
43 | */
|
---|
44 | top(value = '') {
|
---|
45 | this._bottomOffset = '';
|
---|
46 | this._topOffset = value;
|
---|
47 | this._alignItems = 'flex-start';
|
---|
48 | return this;
|
---|
49 | }
|
---|
50 | /**
|
---|
51 | * Sets the left position of the overlay. Clears any previously set horizontal position.
|
---|
52 | * @param value New left offset.
|
---|
53 | */
|
---|
54 | left(value = '') {
|
---|
55 | this._rightOffset = '';
|
---|
56 | this._leftOffset = value;
|
---|
57 | this._justifyContent = 'flex-start';
|
---|
58 | return this;
|
---|
59 | }
|
---|
60 | /**
|
---|
61 | * Sets the bottom position of the overlay. Clears any previously set vertical position.
|
---|
62 | * @param value New bottom offset.
|
---|
63 | */
|
---|
64 | bottom(value = '') {
|
---|
65 | this._topOffset = '';
|
---|
66 | this._bottomOffset = value;
|
---|
67 | this._alignItems = 'flex-end';
|
---|
68 | return this;
|
---|
69 | }
|
---|
70 | /**
|
---|
71 | * Sets the right position of the overlay. Clears any previously set horizontal position.
|
---|
72 | * @param value New right offset.
|
---|
73 | */
|
---|
74 | right(value = '') {
|
---|
75 | this._leftOffset = '';
|
---|
76 | this._rightOffset = value;
|
---|
77 | this._justifyContent = 'flex-end';
|
---|
78 | return this;
|
---|
79 | }
|
---|
80 | /**
|
---|
81 | * Sets the overlay width and clears any previously set width.
|
---|
82 | * @param value New width for the overlay
|
---|
83 | * @deprecated Pass the `width` through the `OverlayConfig`.
|
---|
84 | * @breaking-change 8.0.0
|
---|
85 | */
|
---|
86 | width(value = '') {
|
---|
87 | if (this._overlayRef) {
|
---|
88 | this._overlayRef.updateSize({ width: value });
|
---|
89 | }
|
---|
90 | else {
|
---|
91 | this._width = value;
|
---|
92 | }
|
---|
93 | return this;
|
---|
94 | }
|
---|
95 | /**
|
---|
96 | * Sets the overlay height and clears any previously set height.
|
---|
97 | * @param value New height for the overlay
|
---|
98 | * @deprecated Pass the `height` through the `OverlayConfig`.
|
---|
99 | * @breaking-change 8.0.0
|
---|
100 | */
|
---|
101 | height(value = '') {
|
---|
102 | if (this._overlayRef) {
|
---|
103 | this._overlayRef.updateSize({ height: value });
|
---|
104 | }
|
---|
105 | else {
|
---|
106 | this._height = value;
|
---|
107 | }
|
---|
108 | return this;
|
---|
109 | }
|
---|
110 | /**
|
---|
111 | * Centers the overlay horizontally with an optional offset.
|
---|
112 | * Clears any previously set horizontal position.
|
---|
113 | *
|
---|
114 | * @param offset Overlay offset from the horizontal center.
|
---|
115 | */
|
---|
116 | centerHorizontally(offset = '') {
|
---|
117 | this.left(offset);
|
---|
118 | this._justifyContent = 'center';
|
---|
119 | return this;
|
---|
120 | }
|
---|
121 | /**
|
---|
122 | * Centers the overlay vertically with an optional offset.
|
---|
123 | * Clears any previously set vertical position.
|
---|
124 | *
|
---|
125 | * @param offset Overlay offset from the vertical center.
|
---|
126 | */
|
---|
127 | centerVertically(offset = '') {
|
---|
128 | this.top(offset);
|
---|
129 | this._alignItems = 'center';
|
---|
130 | return this;
|
---|
131 | }
|
---|
132 | /**
|
---|
133 | * Apply the position to the element.
|
---|
134 | * @docs-private
|
---|
135 | */
|
---|
136 | apply() {
|
---|
137 | // Since the overlay ref applies the strategy asynchronously, it could
|
---|
138 | // have been disposed before it ends up being applied. If that is the
|
---|
139 | // case, we shouldn't do anything.
|
---|
140 | if (!this._overlayRef || !this._overlayRef.hasAttached()) {
|
---|
141 | return;
|
---|
142 | }
|
---|
143 | const styles = this._overlayRef.overlayElement.style;
|
---|
144 | const parentStyles = this._overlayRef.hostElement.style;
|
---|
145 | const config = this._overlayRef.getConfig();
|
---|
146 | const { width, height, maxWidth, maxHeight } = config;
|
---|
147 | const shouldBeFlushHorizontally = (width === '100%' || width === '100vw') &&
|
---|
148 | (!maxWidth || maxWidth === '100%' || maxWidth === '100vw');
|
---|
149 | const shouldBeFlushVertically = (height === '100%' || height === '100vh') &&
|
---|
150 | (!maxHeight || maxHeight === '100%' || maxHeight === '100vh');
|
---|
151 | styles.position = this._cssPosition;
|
---|
152 | styles.marginLeft = shouldBeFlushHorizontally ? '0' : this._leftOffset;
|
---|
153 | styles.marginTop = shouldBeFlushVertically ? '0' : this._topOffset;
|
---|
154 | styles.marginBottom = this._bottomOffset;
|
---|
155 | styles.marginRight = this._rightOffset;
|
---|
156 | if (shouldBeFlushHorizontally) {
|
---|
157 | parentStyles.justifyContent = 'flex-start';
|
---|
158 | }
|
---|
159 | else if (this._justifyContent === 'center') {
|
---|
160 | parentStyles.justifyContent = 'center';
|
---|
161 | }
|
---|
162 | else if (this._overlayRef.getConfig().direction === 'rtl') {
|
---|
163 | // In RTL the browser will invert `flex-start` and `flex-end` automatically, but we
|
---|
164 | // don't want that because our positioning is explicitly `left` and `right`, hence
|
---|
165 | // why we do another inversion to ensure that the overlay stays in the same position.
|
---|
166 | // TODO: reconsider this if we add `start` and `end` methods.
|
---|
167 | if (this._justifyContent === 'flex-start') {
|
---|
168 | parentStyles.justifyContent = 'flex-end';
|
---|
169 | }
|
---|
170 | else if (this._justifyContent === 'flex-end') {
|
---|
171 | parentStyles.justifyContent = 'flex-start';
|
---|
172 | }
|
---|
173 | }
|
---|
174 | else {
|
---|
175 | parentStyles.justifyContent = this._justifyContent;
|
---|
176 | }
|
---|
177 | parentStyles.alignItems = shouldBeFlushVertically ? 'flex-start' : this._alignItems;
|
---|
178 | }
|
---|
179 | /**
|
---|
180 | * Cleans up the DOM changes from the position strategy.
|
---|
181 | * @docs-private
|
---|
182 | */
|
---|
183 | dispose() {
|
---|
184 | if (this._isDisposed || !this._overlayRef) {
|
---|
185 | return;
|
---|
186 | }
|
---|
187 | const styles = this._overlayRef.overlayElement.style;
|
---|
188 | const parent = this._overlayRef.hostElement;
|
---|
189 | const parentStyles = parent.style;
|
---|
190 | parent.classList.remove(wrapperClass);
|
---|
191 | parentStyles.justifyContent = parentStyles.alignItems = styles.marginTop =
|
---|
192 | styles.marginBottom = styles.marginLeft = styles.marginRight = styles.position = '';
|
---|
193 | this._overlayRef = null;
|
---|
194 | this._isDisposed = true;
|
---|
195 | }
|
---|
196 | }
|
---|
197 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2xvYmFsLXBvc2l0aW9uLXN0cmF0ZWd5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vc3JjL2Nkay9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