Skip to content

Commit 9c7d330

Browse files
committed
address comments
1 parent 1eee9e7 commit 9c7d330

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {Range} from '@angular/cdk/collections';
9+
import {ListRange} from '@angular/cdk/collections';
1010
import {Directive, forwardRef, Input, OnChanges} from '@angular/core';
1111
import {VIRTUAL_SCROLL_STRATEGY, VirtualScrollStrategy} from './virtual-scroll-strategy';
1212
import {CdkVirtualScrollViewport} from './virtual-scroll-viewport';
@@ -38,7 +38,7 @@ export class ItemSizeAverager {
3838
* @param range The measured range.
3939
* @param size The measured size of the given range in pixels.
4040
*/
41-
addSample(range: Range, size: number) {
41+
addSample(range: ListRange, size: number) {
4242
const weight = range.end - range.start;
4343
const newTotalWeight = this._totalWeight + weight;
4444
if (newTotalWeight) {
@@ -117,7 +117,7 @@ export class AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy {
117117
* @param addBufferPx The number of buffer items to render beyond the edge of the viewport (in
118118
* pixels).
119119
*/
120-
updateBufferSize(minBufferPx, addBufferPx) {
120+
updateBufferSize(minBufferPx: number, addBufferPx: number) {
121121
this._minBufferPx = minBufferPx;
122122
this._addBufferPx = addBufferPx;
123123
}
@@ -148,9 +148,9 @@ export class AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy {
148148
* @param startIndex The index to start the range at
149149
* @return a range estimated to be large enough to fill the viewport when rendered.
150150
*/
151-
private _getVisibleRangeForIndex(startIndex: number): Range {
151+
private _getVisibleRangeForIndex(startIndex: number): ListRange {
152152
const viewport = this._viewport!;
153-
let range = {
153+
const range: ListRange = {
154154
start: startIndex,
155155
end: startIndex +
156156
Math.ceil(viewport.getViewportSize() / this._averager.getAverageItemSize())
@@ -171,7 +171,7 @@ export class AutoSizeVirtualScrollStrategy implements VirtualScrollStrategy {
171171
* @param expandEnd The number of items to expand the end of the range by.
172172
* @return The expanded range.
173173
*/
174-
private _expandRange(range: Range, expandStart: number, expandEnd: number): Range {
174+
private _expandRange(range: ListRange, expandStart: number, expandEnd: number): ListRange {
175175
const viewport = this._viewport!;
176176
const start = Math.max(0, range.start - expandStart);
177177
const end = Math.min(viewport.getDataLength(), range.end + expandEnd);
@@ -210,14 +210,14 @@ export class CdkAutoSizeVirtualScroll implements OnChanges {
210210
* The minimum amount of buffer rendered beyond the viewport (in pixels).
211211
* If the amount of buffer dips below this number, more items will be rendered.
212212
*/
213-
@Input() minBufferPx = 100;
213+
@Input() minBufferPx: number = 100;
214214

215215
/**
216216
* The number of pixels worth of buffer to shoot for when rendering new items.
217217
* If the actual amount turns out to be less it will not necessarily trigger an additional
218218
* rendering cycle (as long as the amount of buffer is still greater than `minBufferPx`).
219219
*/
220-
@Input() addBufferPx = 200;
220+
@Input() addBufferPx: number = 200;
221221

222222
/** The scroll strategy used by this directive. */
223223
_scrollStrategy = new AutoSizeVirtualScrollStrategy(this.minBufferPx, this.addBufferPx);

0 commit comments

Comments
 (0)