Skip to content

Commit 5cd2509

Browse files
committed
refactor(cdk/scrolling): switch to input transforms
Switches inputs in cdk/scrolling to use transforms instead of getters/setters.
1 parent 1dac6ce commit 5cd2509

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

src/cdk/scrolling/virtual-for-of.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import {
3434
TrackByFunction,
3535
ViewContainerRef,
3636
} from '@angular/core';
37-
import {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';
37+
import {NumberInput, coerceNumberProperty} from '@angular/cdk/coercion';
3838
import {Observable, Subject, of as observableOf, isObservable} from 'rxjs';
3939
import {pairwise, shareReplay, startWith, switchMap, takeUntil} from 'rxjs/operators';
4040
import {CdkVirtualScrollRepeater} from './virtual-scroll-repeater';

src/cdk/scrolling/virtual-scroll-viewport.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import {Directionality} from '@angular/cdk/bidi';
1010
import {ListRange} from '@angular/cdk/collections';
1111
import {
12+
booleanAttribute,
1213
ChangeDetectionStrategy,
1314
ChangeDetectorRef,
1415
Component,
@@ -39,7 +40,6 @@ import {CdkScrollable, ExtendedScrollToOptions} from './scrollable';
3940
import {VIRTUAL_SCROLL_STRATEGY, VirtualScrollStrategy} from './virtual-scroll-strategy';
4041
import {ViewportRuler} from './viewport-ruler';
4142
import {CdkVirtualScrollRepeater} from './virtual-scroll-repeater';
42-
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
4343
import {CdkVirtualScrollable, VIRTUAL_SCROLLABLE} from './virtual-scrollable';
4444

4545
/** Checks if the given ranges are equal. */
@@ -106,14 +106,7 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
106106
* Whether rendered items should persist in the DOM after scrolling out of view. By default, items
107107
* will be removed.
108108
*/
109-
@Input()
110-
get appendOnly(): boolean {
111-
return this._appendOnly;
112-
}
113-
set appendOnly(value: BooleanInput) {
114-
this._appendOnly = coerceBooleanProperty(value);
115-
}
116-
private _appendOnly = false;
109+
@Input({transform: booleanAttribute}) appendOnly: boolean = false;
117110

118111
// Note: we don't use the typical EventEmitter here because we need to subscribe to the scroll
119112
// strategy lazily (i.e. only if the user is actually listening to the events). We do this because

tools/public_api_guard/cdk/scrolling.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
55
```ts
66

7-
import { BooleanInput } from '@angular/cdk/coercion';
87
import { ChangeDetectorRef } from '@angular/core';
98
import { CollectionViewer } from '@angular/cdk/collections';
109
import { DataSource } from '@angular/cdk/collections';
@@ -186,8 +185,7 @@ export interface CdkVirtualScrollRepeater<T> {
186185
// @public
187186
export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements OnInit, OnDestroy {
188187
constructor(elementRef: ElementRef<HTMLElement>, _changeDetectorRef: ChangeDetectorRef, ngZone: NgZone, _scrollStrategy: VirtualScrollStrategy, dir: Directionality, scrollDispatcher: ScrollDispatcher, viewportRuler: ViewportRuler, scrollable: CdkVirtualScrollable);
189-
get appendOnly(): boolean;
190-
set appendOnly(value: BooleanInput);
188+
appendOnly: boolean;
191189
attach(forOf: CdkVirtualScrollRepeater<any>): void;
192190
checkViewportSize(): void;
193191
_contentWrapper: ElementRef<HTMLElement>;
@@ -205,6 +203,8 @@ export class CdkVirtualScrollViewport extends CdkVirtualScrollable implements On
205203
measureScrollOffset(from?: 'top' | 'left' | 'right' | 'bottom' | 'start' | 'end'): number;
206204
measureViewportOffset(from?: 'top' | 'left' | 'right' | 'bottom' | 'start' | 'end'): number;
207205
// (undocumented)
206+
static ngAcceptInputType_appendOnly: unknown;
207+
// (undocumented)
208208
ngOnDestroy(): void;
209209
// (undocumented)
210210
ngOnInit(): void;

0 commit comments

Comments
 (0)