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