f6270388ea70b914e5f2c53fb0f0079ed341d9d7
[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-unused-expression*/
11 import {Injectable} from '@angular/core';
12
13 import {ViewportRuler} from '../position/viewport-ruler';
14
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';
21
22
23 /**
24  * Options for how an overlay will handle scrolling.
25  *
26  * Users can provide a custom value for `ScrollStrategyOptions` to replace the
27  * default behaviors. This class primarily acts as a factory for ScrollStrategy
28  * instances.
29  */
30 @Injectable()
31 export class ScrollStrategyOptions {
32   constructor(
33                 private _scrollDispatcher: ScrollDispatcher,
34                 private _viewportRuler: ViewportRuler) {}
35
36   /** Do nothing on scroll. */
37   noop = () => new NoopScrollStrategy();
38
39   /** Close the overlay as soon as the user scrolls. */
40   close = () => new CloseScrollStrategy(this._scrollDispatcher);
41
42   /** Block scrolling. */
43   block = () => new BlockScrollStrategy(this._viewportRuler);
44
45   /**
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.
49    */
50   reposition = (config?: RepositionScrollStrategyConfig) =>
51                 new RepositionScrollStrategy(this._scrollDispatcher, config)
52 }