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 | import { ScrollDispatcher, ViewportRuler } from '@angular/cdk/scrolling';
|
---|
9 | import { DOCUMENT } from '@angular/common';
|
---|
10 | import { Inject, Injectable, NgZone } from '@angular/core';
|
---|
11 | import { BlockScrollStrategy } from './block-scroll-strategy';
|
---|
12 | import { CloseScrollStrategy } from './close-scroll-strategy';
|
---|
13 | import { NoopScrollStrategy } from './noop-scroll-strategy';
|
---|
14 | import { RepositionScrollStrategy, } from './reposition-scroll-strategy';
|
---|
15 | import * as i0 from "@angular/core";
|
---|
16 | import * as i1 from "@angular/cdk/scrolling";
|
---|
17 | import * as i2 from "@angular/common";
|
---|
18 | /**
|
---|
19 | * Options for how an overlay will handle scrolling.
|
---|
20 | *
|
---|
21 | * Users can provide a custom value for `ScrollStrategyOptions` to replace the default
|
---|
22 | * behaviors. This class primarily acts as a factory for ScrollStrategy instances.
|
---|
23 | */
|
---|
24 | export class ScrollStrategyOptions {
|
---|
25 | constructor(_scrollDispatcher, _viewportRuler, _ngZone, document) {
|
---|
26 | this._scrollDispatcher = _scrollDispatcher;
|
---|
27 | this._viewportRuler = _viewportRuler;
|
---|
28 | this._ngZone = _ngZone;
|
---|
29 | /** Do nothing on scroll. */
|
---|
30 | this.noop = () => new NoopScrollStrategy();
|
---|
31 | /**
|
---|
32 | * Close the overlay as soon as the user scrolls.
|
---|
33 | * @param config Configuration to be used inside the scroll strategy.
|
---|
34 | */
|
---|
35 | this.close = (config) => new CloseScrollStrategy(this._scrollDispatcher, this._ngZone, this._viewportRuler, config);
|
---|
36 | /** Block scrolling. */
|
---|
37 | this.block = () => new BlockScrollStrategy(this._viewportRuler, this._document);
|
---|
38 | /**
|
---|
39 | * Update the overlay's position on scroll.
|
---|
40 | * @param config Configuration to be used inside the scroll strategy.
|
---|
41 | * Allows debouncing the reposition calls.
|
---|
42 | */
|
---|
43 | this.reposition = (config) => new RepositionScrollStrategy(this._scrollDispatcher, this._viewportRuler, this._ngZone, config);
|
---|
44 | this._document = document;
|
---|
45 | }
|
---|
46 | }
|
---|
47 | ScrollStrategyOptions.ɵprov = i0.ɵɵdefineInjectable({ factory: function ScrollStrategyOptions_Factory() { return new ScrollStrategyOptions(i0.ɵɵinject(i1.ScrollDispatcher), i0.ɵɵinject(i1.ViewportRuler), i0.ɵɵinject(i0.NgZone), i0.ɵɵinject(i2.DOCUMENT)); }, token: ScrollStrategyOptions, providedIn: "root" });
|
---|
48 | ScrollStrategyOptions.decorators = [
|
---|
49 | { type: Injectable, args: [{ providedIn: 'root' },] }
|
---|
50 | ];
|
---|
51 | ScrollStrategyOptions.ctorParameters = () => [
|
---|
52 | { type: ScrollDispatcher },
|
---|
53 | { type: ViewportRuler },
|
---|
54 | { type: NgZone },
|
---|
55 | { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
|
---|
56 | ];
|
---|
57 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsLXN0cmF0ZWd5LW9wdGlvbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL292ZXJsYXkvc2Nyb2xsL3Njcm9sbC1zdHJhdGVneS1vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxnQkFBZ0IsRUFBRSxhQUFhLEVBQUMsTUFBTSx3QkFBd0IsQ0FBQztBQUN2RSxPQUFPLEVBQUMsUUFBUSxFQUFDLE1BQU0saUJBQWlCLENBQUM7QUFDekMsT0FBTyxFQUFDLE1BQU0sRUFBRSxVQUFVLEVBQUUsTUFBTSxFQUFDLE1BQU0sZUFBZSxDQUFDO0FB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