6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { Range } from '@angular/cdk/collections' ;
9
+ import { ListRange } from '@angular/cdk/collections' ;
10
10
import { Directive , forwardRef , Input , OnChanges } from '@angular/core' ;
11
11
import { VIRTUAL_SCROLL_STRATEGY , VirtualScrollStrategy } from './virtual-scroll-strategy' ;
12
12
import { CdkVirtualScrollViewport } from './virtual-scroll-viewport' ;
@@ -38,7 +38,7 @@ export class ItemSizeAverager {
38
38
* @param range The measured range.
39
39
* @param size The measured size of the given range in pixels.
40
40
*/
41
- addSample ( range : Range , size : number ) {
41
+ addSample ( range : ListRange , size : number ) {
42
42
const weight = range . end - range . start ;
43
43
const newTotalWeight = this . _totalWeight + weight ;
44
44
if ( newTotalWeight ) {
@@ -117,7 +117,7 @@ export class AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy {
117
117
* @param addBufferPx The number of buffer items to render beyond the edge of the viewport (in
118
118
* pixels).
119
119
*/
120
- updateBufferSize ( minBufferPx , addBufferPx ) {
120
+ updateBufferSize ( minBufferPx : number , addBufferPx : number ) {
121
121
this . _minBufferPx = minBufferPx ;
122
122
this . _addBufferPx = addBufferPx ;
123
123
}
@@ -148,9 +148,9 @@ export class AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy {
148
148
* @param startIndex The index to start the range at
149
149
* @return a range estimated to be large enough to fill the viewport when rendered.
150
150
*/
151
- private _getVisibleRangeForIndex ( startIndex : number ) : Range {
151
+ private _getVisibleRangeForIndex ( startIndex : number ) : ListRange {
152
152
const viewport = this . _viewport ! ;
153
- let range = {
153
+ const range : ListRange = {
154
154
start : startIndex ,
155
155
end : startIndex +
156
156
Math . ceil ( viewport . getViewportSize ( ) / this . _averager . getAverageItemSize ( ) )
@@ -171,7 +171,7 @@ export class AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy {
171
171
* @param expandEnd The number of items to expand the end of the range by.
172
172
* @return The expanded range.
173
173
*/
174
- private _expandRange ( range : Range , expandStart : number , expandEnd : number ) : Range {
174
+ private _expandRange ( range : ListRange , expandStart : number , expandEnd : number ) : ListRange {
175
175
const viewport = this . _viewport ! ;
176
176
const start = Math . max ( 0 , range . start - expandStart ) ;
177
177
const end = Math . min ( viewport . getDataLength ( ) , range . end + expandEnd ) ;
@@ -210,14 +210,14 @@ export class CdkAutoSizeVirtualScroll implements OnChanges {
210
210
* The minimum amount of buffer rendered beyond the viewport (in pixels).
211
211
* If the amount of buffer dips below this number, more items will be rendered.
212
212
*/
213
- @Input ( ) minBufferPx = 100 ;
213
+ @Input ( ) minBufferPx : number = 100 ;
214
214
215
215
/**
216
216
* The number of pixels worth of buffer to shoot for when rendering new items.
217
217
* If the actual amount turns out to be less it will not necessarily trigger an additional
218
218
* rendering cycle (as long as the amount of buffer is still greater than `minBufferPx`).
219
219
*/
220
- @Input ( ) addBufferPx = 200 ;
220
+ @Input ( ) addBufferPx : number = 200 ;
221
221
222
222
/** The scroll strategy used by this directive. */
223
223
_scrollStrategy = new AutoSizeVirtualScrollStrategy ( this . minBufferPx , this . addBufferPx ) ;
0 commit comments