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 { Directionality } from '@angular/cdk/bidi';
|
---|
9 | import { ListRange } from '@angular/cdk/collections';
|
---|
10 | import { ChangeDetectorRef, ElementRef, NgZone, OnDestroy, OnInit } from '@angular/core';
|
---|
11 | import { Observable } from 'rxjs';
|
---|
12 | import { ScrollDispatcher } from './scroll-dispatcher';
|
---|
13 | import { CdkScrollable } from './scrollable';
|
---|
14 | import { VirtualScrollStrategy } from './virtual-scroll-strategy';
|
---|
15 | import { ViewportRuler } from './viewport-ruler';
|
---|
16 | import { CdkVirtualScrollRepeater } from './virtual-scroll-repeater';
|
---|
17 | import { BooleanInput } from '@angular/cdk/coercion';
|
---|
18 | /** A viewport that virtualizes its scrolling with the help of `CdkVirtualForOf`. */
|
---|
19 | export declare class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, OnDestroy {
|
---|
20 | elementRef: ElementRef<HTMLElement>;
|
---|
21 | private _changeDetectorRef;
|
---|
22 | private _scrollStrategy;
|
---|
23 | /** Emits when the viewport is detached from a CdkVirtualForOf. */
|
---|
24 | private readonly _detachedSubject;
|
---|
25 | /** Emits when the rendered range changes. */
|
---|
26 | private readonly _renderedRangeSubject;
|
---|
27 | /** The direction the viewport scrolls. */
|
---|
28 | get orientation(): 'horizontal' | 'vertical';
|
---|
29 | set orientation(orientation: 'horizontal' | 'vertical');
|
---|
30 | private _orientation;
|
---|
31 | /**
|
---|
32 | * Whether rendered items should persist in the DOM after scrolling out of view. By default, items
|
---|
33 | * will be removed.
|
---|
34 | */
|
---|
35 | get appendOnly(): boolean;
|
---|
36 | set appendOnly(value: boolean);
|
---|
37 | private _appendOnly;
|
---|
38 | /** Emits when the index of the first element visible in the viewport changes. */
|
---|
39 | readonly scrolledIndexChange: Observable<number>;
|
---|
40 | /** The element that wraps the rendered content. */
|
---|
41 | _contentWrapper: ElementRef<HTMLElement>;
|
---|
42 | /** A stream that emits whenever the rendered range changes. */
|
---|
43 | readonly renderedRangeStream: Observable<ListRange>;
|
---|
44 | /**
|
---|
45 | * The total size of all content (in pixels), including content that is not currently rendered.
|
---|
46 | */
|
---|
47 | private _totalContentSize;
|
---|
48 | /** A string representing the `style.width` property value to be used for the spacer element. */
|
---|
49 | _totalContentWidth: string;
|
---|
50 | /** A string representing the `style.height` property value to be used for the spacer element. */
|
---|
51 | _totalContentHeight: string;
|
---|
52 | /**
|
---|
53 | * The CSS transform applied to the rendered subset of items so that they appear within the bounds
|
---|
54 | * of the visible viewport.
|
---|
55 | */
|
---|
56 | private _renderedContentTransform;
|
---|
57 | /** The currently rendered range of indices. */
|
---|
58 | private _renderedRange;
|
---|
59 | /** The length of the data bound to this viewport (in number of items). */
|
---|
60 | private _dataLength;
|
---|
61 | /** The size of the viewport (in pixels). */
|
---|
62 | private _viewportSize;
|
---|
63 | /** the currently attached CdkVirtualScrollRepeater. */
|
---|
64 | private _forOf;
|
---|
65 | /** The last rendered content offset that was set. */
|
---|
66 | private _renderedContentOffset;
|
---|
67 | /**
|
---|
68 | * Whether the last rendered content offset was to the end of the content (and therefore needs to
|
---|
69 | * be rewritten as an offset to the start of the content).
|
---|
70 | */
|
---|
71 | private _renderedContentOffsetNeedsRewrite;
|
---|
72 | /** Whether there is a pending change detection cycle. */
|
---|
73 | private _isChangeDetectionPending;
|
---|
74 | /** A list of functions to run after the next change detection cycle. */
|
---|
75 | private _runAfterChangeDetection;
|
---|
76 | /** Subscription to changes in the viewport size. */
|
---|
77 | private _viewportChanges;
|
---|
78 | constructor(elementRef: ElementRef<HTMLElement>, _changeDetectorRef: ChangeDetectorRef, ngZone: NgZone, _scrollStrategy: VirtualScrollStrategy, dir: Directionality, scrollDispatcher: ScrollDispatcher, viewportRuler: ViewportRuler);
|
---|
79 | ngOnInit(): void;
|
---|
80 | ngOnDestroy(): void;
|
---|
81 | /** Attaches a `CdkVirtualScrollRepeater` to this viewport. */
|
---|
82 | attach(forOf: CdkVirtualScrollRepeater<any>): void;
|
---|
83 | /** Detaches the current `CdkVirtualForOf`. */
|
---|
84 | detach(): void;
|
---|
85 | /** Gets the length of the data bound to this viewport (in number of items). */
|
---|
86 | getDataLength(): number;
|
---|
87 | /** Gets the size of the viewport (in pixels). */
|
---|
88 | getViewportSize(): number;
|
---|
89 | /** Get the current rendered range of items. */
|
---|
90 | getRenderedRange(): ListRange;
|
---|
91 | /**
|
---|
92 | * Sets the total size of all content (in pixels), including content that is not currently
|
---|
93 | * rendered.
|
---|
94 | */
|
---|
95 | setTotalContentSize(size: number): void;
|
---|
96 | /** Sets the currently rendered range of indices. */
|
---|
97 | setRenderedRange(range: ListRange): void;
|
---|
98 | /**
|
---|
99 | * Gets the offset from the start of the viewport to the start of the rendered data (in pixels).
|
---|
100 | */
|
---|
101 | getOffsetToRenderedContentStart(): number | null;
|
---|
102 | /**
|
---|
103 | * Sets the offset from the start of the viewport to either the start or end of the rendered data
|
---|
104 | * (in pixels).
|
---|
105 | */
|
---|
106 | setRenderedContentOffset(offset: number, to?: 'to-start' | 'to-end'): void;
|
---|
107 | /**
|
---|
108 | * Scrolls to the given offset from the start of the viewport. Please note that this is not always
|
---|
109 | * the same as setting `scrollTop` or `scrollLeft`. In a horizontal viewport with right-to-left
|
---|
110 | * direction, this would be the equivalent of setting a fictional `scrollRight` property.
|
---|
111 | * @param offset The offset to scroll to.
|
---|
112 | * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
|
---|
113 | */
|
---|
114 | scrollToOffset(offset: number, behavior?: ScrollBehavior): void;
|
---|
115 | /**
|
---|
116 | * Scrolls to the offset for the given index.
|
---|
117 | * @param index The index of the element to scroll to.
|
---|
118 | * @param behavior The ScrollBehavior to use when scrolling. Default is behavior is `auto`.
|
---|
119 | */
|
---|
120 | scrollToIndex(index: number, behavior?: ScrollBehavior): void;
|
---|
121 | /**
|
---|
122 | * Gets the current scroll offset from the start of the viewport (in pixels).
|
---|
123 | * @param from The edge to measure the offset from. Defaults to 'top' in vertical mode and 'start'
|
---|
124 | * in horizontal mode.
|
---|
125 | */
|
---|
126 | measureScrollOffset(from?: 'top' | 'left' | 'right' | 'bottom' | 'start' | 'end'): number;
|
---|
127 | /** Measure the combined size of all of the rendered items. */
|
---|
128 | measureRenderedContentSize(): number;
|
---|
129 | /**
|
---|
130 | * Measure the total combined size of the given range. Throws if the range includes items that are
|
---|
131 | * not rendered.
|
---|
132 | */
|
---|
133 | measureRangeSize(range: ListRange): number;
|
---|
134 | /** Update the viewport dimensions and re-render. */
|
---|
135 | checkViewportSize(): void;
|
---|
136 | /** Measure the viewport size. */
|
---|
137 | private _measureViewportSize;
|
---|
138 | /** Queue up change detection to run. */
|
---|
139 | private _markChangeDetectionNeeded;
|
---|
140 | /** Run change detection. */
|
---|
141 | private _doChangeDetection;
|
---|
142 | /** Calculates the `style.width` and `style.height` for the spacer element. */
|
---|
143 | private _calculateSpacerSize;
|
---|
144 | static ngAcceptInputType_appendOnly: BooleanInput;
|
---|
145 | }
|
---|