@@ -106,7 +106,8 @@ export class CdkOverlayOrigin {
106106
107107
108108/**
109- * Directive to facilitate declarative creation of an Overlay using a ConnectedPositionStrategy.
109+ * Directive to facilitate declarative creation of an
110+ * Overlay using a FlexibleConnectedPositionStrategy.
110111 */
111112@Directive ( {
112113 selector : '[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]' ,
@@ -117,6 +118,9 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
117118 private _templatePortal : TemplatePortal ;
118119 private _hasBackdrop = false ;
119120 private _lockPosition = false ;
121+ private _growAfterOpen = false ;
122+ private _flexibleDimensions = false ;
123+ private _push = false ;
120124 private _backdropSubscription = Subscription . EMPTY ;
121125 private _offsetX : number ;
122126 private _offsetY : number ;
@@ -165,6 +169,9 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
165169 /** The custom class to be set on the backdrop element. */
166170 @Input ( 'cdkConnectedOverlayBackdropClass' ) backdropClass : string ;
167171
172+ /** Margin between the overlay and the viewport edges. */
173+ @Input ( 'cdkConnectedOverlayViewportMargin' ) viewportMargin : number = 0 ;
174+
168175 /** Strategy to be used when handling scroll events while the overlay is open. */
169176 @Input ( 'cdkConnectedOverlayScrollStrategy' ) scrollStrategy : ScrollStrategy =
170177 this . _scrollStrategy ( ) ;
@@ -182,6 +189,21 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
182189 get lockPosition ( ) { return this . _lockPosition ; }
183190 set lockPosition ( value : any ) { this . _lockPosition = coerceBooleanProperty ( value ) ; }
184191
192+ /** Whether the overlay's width and height can be constrained to fit within the viewport. */
193+ @Input ( 'cdkConnectedOverlayFlexibleDimensions' )
194+ get flexibleDiemsions ( ) { return this . _flexibleDimensions ; }
195+ set flexibleDiemsions ( value : boolean ) { this . _flexibleDimensions = coerceBooleanProperty ( value ) ; }
196+
197+ /** Whether the overlay can grow after the initial open when flexible positioning is turned on. */
198+ @Input ( 'cdkConnectedOverlayGrowAfterOpen' )
199+ get growAfterOpen ( ) { return this . _growAfterOpen ; }
200+ set growAfterOpen ( value : boolean ) { this . _growAfterOpen = coerceBooleanProperty ( value ) ; }
201+
202+ /** Whether the overlay can be pushed on-screen if none of the provided positions fit. */
203+ @Input ( 'cdkConnectedOverlayPush' )
204+ get push ( ) { return this . _push ; }
205+ set push ( value : boolean ) { this . _push = coerceBooleanProperty ( value ) ; }
206+
185207 /** Event emitted when the backdrop is clicked. */
186208 @Output ( ) backdropClick = new EventEmitter < MouseEvent > ( ) ;
187209
@@ -288,13 +310,10 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
288310 private _createPositionStrategy ( ) : FlexibleConnectedPositionStrategy {
289311 const strategy = this . _overlay . position ( )
290312 . flexibleConnectedTo ( this . origin . elementRef )
291- // Turn off all of the flexible positioning features for now to have it behave
292- // the same way as the old ConnectedPositionStrategy and to avoid breaking changes.
293- // TODO(crisbeto): make these on by default and add inputs for them
294- // next time we do breaking changes.
295- . withFlexibleDimensions ( false )
296- . withPush ( false )
297- . withGrowAfterOpen ( false )
313+ . withFlexibleDimensions ( this . flexibleDiemsions )
314+ . withPush ( this . push )
315+ . withGrowAfterOpen ( this . growAfterOpen )
316+ . withViewportMargin ( this . viewportMargin )
298317 . withLockedPosition ( this . lockPosition ) ;
299318
300319 this . _setPositions ( strategy ) ;
0 commit comments