@@ -19,6 +19,8 @@ import {
1919 Renderer2 ,
2020 OnChanges ,
2121 SimpleChanges ,
22+ InjectionToken ,
23+ Inject ,
2224} from '@angular/core' ;
2325import { Overlay } from './overlay' ;
2426import { OverlayRef } from './overlay-ref' ;
@@ -30,15 +32,14 @@ import {
3032} from './position/connected-position' ;
3133import { ConnectedPositionStrategy } from './position/connected-position-strategy' ;
3234import { Directionality , Direction } from '../bidi/index' ;
33- import { Scrollable } from './scroll/scrollable' ;
34- import { ScrollStrategy } from './scroll/scroll-strategy' ;
35+ import { ScrollStrategy , Scrollable , RepositionScrollStrategy } from './scroll/index' ;
3536import { coerceBooleanProperty } from '../coercion/boolean-property' ;
3637import { ESCAPE } from '../keyboard/keycodes' ;
3738import { Subscription } from 'rxjs/Subscription' ;
3839
3940
4041/** Default set of positions for the overlay. Follows the behavior of a dropdown. */
41- let defaultPositionList = [
42+ const defaultPositionList = [
4243 new ConnectionPositionPair (
4344 { originX : 'start' , originY : 'bottom' } ,
4445 { overlayX : 'start' , overlayY : 'top' } ) ,
@@ -47,6 +48,23 @@ let defaultPositionList = [
4748 { overlayX : 'start' , overlayY : 'bottom' } ) ,
4849] ;
4950
51+ /** Injection token that determines the scroll handling while the connected overlay is open. */
52+ export const MD_CONNECTED_OVERLAY_SCROLL_STRATEGY =
53+ new InjectionToken < ( ) => ScrollStrategy > ( 'md-connected-overlay-scroll-strategy' ) ;
54+
55+ /** @docs -private */
56+ export function MD_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY ( overlay : Overlay ) {
57+ return ( ) => overlay . scrollStrategies . reposition ( ) ;
58+ }
59+
60+ /** @docs -private */
61+ export const MD_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER = {
62+ provide : MD_CONNECTED_OVERLAY_SCROLL_STRATEGY ,
63+ deps : [ Overlay ] ,
64+ useFactory : MD_CONNECTED_OVERLAY_SCROLL_STRATEGY_PROVIDER_FACTORY ,
65+ } ;
66+
67+
5068
5169/**
5270 * Directive applied to an element to make it usable as an origin for an Overlay using a
@@ -128,7 +146,7 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
128146 @Input ( ) backdropClass : string ;
129147
130148 /** Strategy to be used when handling scroll events while the overlay is open. */
131- @Input ( ) scrollStrategy : ScrollStrategy = this . _overlay . scrollStrategies . reposition ( ) ;
149+ @Input ( ) scrollStrategy : ScrollStrategy = this . _scrollStrategy ( ) ;
132150
133151 /** Whether the overlay is open. */
134152 @Input ( ) open : boolean = false ;
@@ -162,6 +180,7 @@ export class ConnectedOverlayDirective implements OnDestroy, OnChanges {
162180 private _renderer : Renderer2 ,
163181 templateRef : TemplateRef < any > ,
164182 viewContainerRef : ViewContainerRef ,
183+ @Inject ( MD_CONNECTED_OVERLAY_SCROLL_STRATEGY ) private _scrollStrategy ,
165184 @Optional ( ) private _dir : Directionality ) {
166185 this . _templatePortal = new TemplatePortal ( templateRef , viewContainerRef ) ;
167186 }
0 commit comments