3 * Copyright Google Inc. All Rights Reserved.
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
8 /* tslint:disable:array-type member-access variable-name typedef
9 only-arrow-functions directive-class-suffix component-class-suffix
10 component-selector no-unused-expression*/
11 import {Injectable} from '@angular/core';
13 import {ViewportRuler} from '../position/viewport-ruler';
15 import {BlockScrollStrategy} from './block-scroll-strategy';
16 import {CloseScrollStrategy} from './close-scroll-strategy';
17 import {NoopScrollStrategy} from './noop-scroll-strategy';
18 import {RepositionScrollStrategy, RepositionScrollStrategyConfig} from './reposition-scroll-strategy';
19 import {ScrollDispatcher} from './scroll-dispatcher';
20 // import {ScrollStrategy} from './scroll-strategy';
24 * Options for how an overlay will handle scrolling.
26 * Users can provide a custom value for `ScrollStrategyOptions` to replace the
27 * default behaviors. This class primarily acts as a factory for ScrollStrategy
31 export class ScrollStrategyOptions {
33 private _scrollDispatcher: ScrollDispatcher,
34 private _viewportRuler: ViewportRuler) {}
36 /** Do nothing on scroll. */
37 noop = () => new NoopScrollStrategy();
39 /** Close the overlay as soon as the user scrolls. */
40 close = () => new CloseScrollStrategy(this._scrollDispatcher);
42 /** Block scrolling. */
43 block = () => new BlockScrollStrategy(this._viewportRuler);
46 * Update the overlay's position on scroll.
47 * @param config Configuration to be used inside the scroll strategy.
48 * Allows debouncing the reposition calls.
50 reposition = (config?: RepositionScrollStrategyConfig) =>
51 new RepositionScrollStrategy(this._scrollDispatcher, config)