Skip to content

virtual-scroll: rename Range to ListRange to avoid confusion with native Range #10220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cdk-experimental/scrolling/virtual-for-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ArrayDataSource, CollectionViewer, DataSource, Range} from '@angular/cdk/collections';
import {ArrayDataSource, CollectionViewer, DataSource, ListRange} from '@angular/cdk/collections';
import {
Directive,
DoCheck,
Expand Down Expand Up @@ -54,7 +54,7 @@ export type CdkVirtualForOfContext<T> = {
})
export class CdkVirtualForOf<T> implements CollectionViewer, DoCheck, OnDestroy {
/** Emits when the rendered view of the data changes. */
viewChange = new Subject<Range>();
viewChange = new Subject<ListRange>();

/** Subject that emits when a new DataSource instance is given. */
private _dataSourceChanges = new Subject<DataSource<T>>();
Expand Down Expand Up @@ -124,7 +124,7 @@ export class CdkVirtualForOf<T> implements CollectionViewer, DoCheck, OnDestroy
private _renderedItems: T[];

/** The currently rendered range of indices. */
private _renderedRange: Range;
private _renderedRange: ListRange;

/**
* The template cache used to hold on ot template instancess that have been stamped out, but don't
Expand Down Expand Up @@ -221,7 +221,7 @@ export class CdkVirtualForOf<T> implements CollectionViewer, DoCheck, OnDestroy
}

/** React to scroll state changes in the viewport. */
private _onRenderedRangeChange(renderedRange: Range) {
private _onRenderedRangeChange(renderedRange: ListRange) {
this._renderedRange = renderedRange;
this.viewChange.next(this._renderedRange);
this._renderedItems = this._data.slice(this._renderedRange.start, this._renderedRange.end);
Expand Down
4 changes: 2 additions & 2 deletions src/cdk-experimental/scrolling/virtual-scroll-fixed-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Range} from '@angular/cdk/collections';
import {ListRange} from '@angular/cdk/collections';
import {Directive, forwardRef, Input, OnChanges} from '@angular/core';
import {VIRTUAL_SCROLL_STRATEGY, VirtualScrollStrategy} from './virtual-scroll-strategy';
import {CdkVirtualScrollViewport} from './virtual-scroll-viewport';
Expand Down Expand Up @@ -102,7 +102,7 @@ export class VirtualScrollFixedSizeStrategy implements VirtualScrollStrategy {
* @param expandEnd The number of items to expand the end of the range by.
* @return The expanded range.
*/
private _expandRange(range: Range, expandStart: number, expandEnd: number): Range {
private _expandRange(range: ListRange, expandStart: number, expandEnd: number): ListRange {
if (!this._viewport) {
return {...range};
}
Expand Down
12 changes: 6 additions & 6 deletions src/cdk-experimental/scrolling/virtual-scroll-viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {Range} from '@angular/cdk/collections';
import {ListRange} from '@angular/cdk/collections';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Expand All @@ -31,7 +31,7 @@ import {VIRTUAL_SCROLL_STRATEGY, VirtualScrollStrategy} from './virtual-scroll-s


/** Checks if the given ranges are equal. */
function rangesEqual(r1: Range, r2: Range): boolean {
function rangesEqual(r1: ListRange, r2: ListRange): boolean {
return r1.start == r2.start && r1.end == r2.end;
}

Expand All @@ -54,7 +54,7 @@ export class CdkVirtualScrollViewport implements OnInit, OnDestroy {
private _detachedSubject = new Subject<void>();

/** Emits when the rendered range changes. */
private _renderedRangeSubject = new Subject<Range>();
private _renderedRangeSubject = new Subject<ListRange>();

/** The direction the viewport scrolls. */
@Input() orientation: 'horizontal' | 'vertical' = 'vertical';
Expand All @@ -63,7 +63,7 @@ export class CdkVirtualScrollViewport implements OnInit, OnDestroy {
@ViewChild('contentWrapper') _contentWrapper: ElementRef;

/** A stream that emits whenever the rendered range changes. */
renderedRangeStream: Observable<Range> = this._renderedRangeSubject.asObservable();
renderedRangeStream: Observable<ListRange> = this._renderedRangeSubject.asObservable();

/**
* The total size of all content (in pixels), including content that is not currently rendered.
Expand All @@ -74,7 +74,7 @@ export class CdkVirtualScrollViewport implements OnInit, OnDestroy {
_renderedContentTransform: string;

/** The currently rendered range of indices. */
private _renderedRange: Range = {start: 0, end: 0};
private _renderedRange: ListRange = {start: 0, end: 0};

/** The length of the data bound to this viewport (in number of items). */
private _dataLength = 0;
Expand Down Expand Up @@ -116,7 +116,7 @@ export class CdkVirtualScrollViewport implements OnInit, OnDestroy {
}

/** Sets the currently rendered range of indices. */
setRenderedRange(range: Range) {
setRenderedRange(range: ListRange) {
if (!rangesEqual(this._renderedRange, range)) {
// Re-enter the Angular zone so we can mark for change detection.
this._ngZone.run(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/collections/collection-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Observable} from 'rxjs/Observable';


/** Represents a range of numbers with a specified start and end. */
export type Range = {start: number, end: number};
export type ListRange = {start: number, end: number};


/**
Expand All @@ -22,5 +22,5 @@ export interface CollectionViewer {
* A stream that emits whenever the `CollectionViewer` starts looking at a new portion of the
* data. The `start` index is inclusive, while the `end` is exclusive.
*/
viewChange: Observable<Range>;
viewChange: Observable<ListRange>;
}