@@ -234,6 +234,7 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
234
234
} ;
235
235
_queue : number = SCROLL_QUEUE_NO_CHANGES ;
236
236
_recordSize : number = 0 ;
237
+ _virtualTrackBy : TrackByFn ;
237
238
238
239
@ContentChild ( VirtualItem ) _itmTmp : VirtualItem ;
239
240
@ContentChild ( VirtualHeader ) _hdrTmp : VirtualHeader ;
@@ -249,9 +250,7 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
249
250
@Input ( )
250
251
set virtualScroll ( val : any ) {
251
252
this . _records = val ;
252
- if ( isBlank ( this . _differ ) && isPresent ( val ) ) {
253
- this . _differ = this . _iterableDiffers . find ( val ) . create ( this . virtualTrackBy ) ;
254
- }
253
+ this . _updateDiffer ( ) ;
255
254
}
256
255
257
256
/**
@@ -368,7 +367,12 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
368
367
/**
369
368
* @input {function} Same as `ngForTrackBy` which can be used on `ngFor`.
370
369
*/
371
- @Input ( ) virtualTrackBy : TrackByFn ;
370
+ @Input ( )
371
+ set virtualTrackBy ( val : TrackByFn ) {
372
+ if ( ! isPresent ( val ) ) return ;
373
+ this . _virtualTrackBy = val ;
374
+ this . _updateDiffer ( ) ;
375
+ } ;
372
376
373
377
374
378
constructor (
@@ -481,6 +485,12 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
481
485
return null ;
482
486
}
483
487
488
+ private _updateDiffer ( ) : void {
489
+ if ( isBlank ( this . _differ ) && isPresent ( this . _records ) ) {
490
+ this . _differ = this . _iterableDiffers . find ( this . _records ) . create ( this . virtualTrackBy ) ;
491
+ }
492
+ }
493
+
484
494
/**
485
495
* @hidden
486
496
* DOM WRITE
@@ -632,7 +642,7 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
632
642
var stopAtHeight = ( data . scrollTop + data . renderHeight ) ;
633
643
634
644
processRecords ( stopAtHeight , records , cells ,
635
- this . _hdrFn , this . _ftrFn , data ) ;
645
+ this . _hdrFn , this . _ftrFn , data ) ;
636
646
}
637
647
638
648
// ******** DOM READ ****************
0 commit comments