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 { Platform } from '@angular/cdk/platform';
|
---|
9 | import { ElementRef, NgZone, OnDestroy } from '@angular/core';
|
---|
10 | import { Subscription, Observable } from 'rxjs';
|
---|
11 | import { CdkScrollable } from './scrollable';
|
---|
12 | /** Time in ms to throttle the scrolling events by default. */
|
---|
13 | import * as ɵngcc0 from '@angular/core';
|
---|
14 | export declare const DEFAULT_SCROLL_TIME = 20;
|
---|
15 | /**
|
---|
16 | * Service contained all registered Scrollable references and emits an event when any one of the
|
---|
17 | * Scrollable references emit a scrolled event.
|
---|
18 | */
|
---|
19 | export declare class ScrollDispatcher implements OnDestroy {
|
---|
20 | private _ngZone;
|
---|
21 | private _platform;
|
---|
22 | /** Used to reference correct document/window */
|
---|
23 | protected _document: Document;
|
---|
24 | constructor(_ngZone: NgZone, _platform: Platform, document: any);
|
---|
25 | /** Subject for notifying that a registered scrollable reference element has been scrolled. */
|
---|
26 | private readonly _scrolled;
|
---|
27 | /** Keeps track of the global `scroll` and `resize` subscriptions. */
|
---|
28 | _globalSubscription: Subscription | null;
|
---|
29 | /** Keeps track of the amount of subscriptions to `scrolled`. Used for cleaning up afterwards. */
|
---|
30 | private _scrolledCount;
|
---|
31 | /**
|
---|
32 | * Map of all the scrollable references that are registered with the service and their
|
---|
33 | * scroll event subscriptions.
|
---|
34 | */
|
---|
35 | scrollContainers: Map<CdkScrollable, Subscription>;
|
---|
36 | /**
|
---|
37 | * Registers a scrollable instance with the service and listens for its scrolled events. When the
|
---|
38 | * scrollable is scrolled, the service emits the event to its scrolled observable.
|
---|
39 | * @param scrollable Scrollable instance to be registered.
|
---|
40 | */
|
---|
41 | register(scrollable: CdkScrollable): void;
|
---|
42 | /**
|
---|
43 | * Deregisters a Scrollable reference and unsubscribes from its scroll event observable.
|
---|
44 | * @param scrollable Scrollable instance to be deregistered.
|
---|
45 | */
|
---|
46 | deregister(scrollable: CdkScrollable): void;
|
---|
47 | /**
|
---|
48 | * Returns an observable that emits an event whenever any of the registered Scrollable
|
---|
49 | * references (or window, document, or body) fire a scrolled event. Can provide a time in ms
|
---|
50 | * to override the default "throttle" time.
|
---|
51 | *
|
---|
52 | * **Note:** in order to avoid hitting change detection for every scroll event,
|
---|
53 | * all of the events emitted from this stream will be run outside the Angular zone.
|
---|
54 | * If you need to update any data bindings as a result of a scroll event, you have
|
---|
55 | * to run the callback using `NgZone.run`.
|
---|
56 | */
|
---|
57 | scrolled(auditTimeInMs?: number): Observable<CdkScrollable | void>;
|
---|
58 | ngOnDestroy(): void;
|
---|
59 | /**
|
---|
60 | * Returns an observable that emits whenever any of the
|
---|
61 | * scrollable ancestors of an element are scrolled.
|
---|
62 | * @param elementOrElementRef Element whose ancestors to listen for.
|
---|
63 | * @param auditTimeInMs Time to throttle the scroll events.
|
---|
64 | */
|
---|
65 | ancestorScrolled(elementOrElementRef: ElementRef | HTMLElement, auditTimeInMs?: number): Observable<CdkScrollable | void>;
|
---|
66 | /** Returns all registered Scrollables that contain the provided element. */
|
---|
67 | getAncestorScrollContainers(elementOrElementRef: ElementRef | HTMLElement): CdkScrollable[];
|
---|
68 | /** Use defaultView of injected document if available or fallback to global window reference */
|
---|
69 | private _getWindow;
|
---|
70 | /** Returns true if the element is contained within the provided Scrollable. */
|
---|
71 | private _scrollableContainsElement;
|
---|
72 | /** Sets up the global scroll listeners. */
|
---|
73 | private _addGlobalListener;
|
---|
74 | /** Cleans up the global scroll listener. */
|
---|
75 | private _removeGlobalListener;
|
---|
76 | static ɵfac: ɵngcc0.ɵɵFactoryDeclaration<ScrollDispatcher, [null, null, { optional: true; }]>;
|
---|
77 | }
|
---|
78 |
|
---|
79 | //# sourceMappingURL=scroll-dispatcher.d.ts.map |
---|