@@ -379,7 +379,6 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
379
379
return this . _virtualTrackBy ;
380
380
}
381
381
382
-
383
382
constructor (
384
383
private _iterableDiffers : IterableDiffers ,
385
384
private _elementRef : ElementRef ,
@@ -412,6 +411,28 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
412
411
} ) ;
413
412
}
414
413
414
+ /**
415
+ * @hidden
416
+ */
417
+ firstRecord ( ) : number {
418
+ const cells = this . _cells ;
419
+ if ( cells . length > 0 ) {
420
+ return cells [ 0 ] . record ;
421
+ }
422
+ return 0 ;
423
+ }
424
+
425
+ /**
426
+ * @hidden
427
+ */
428
+ lastRecord ( ) : number {
429
+ const cells = this . _cells ;
430
+ if ( cells . length > 0 ) {
431
+ return cells [ cells . length - 1 ] . record ;
432
+ }
433
+ return 0 ;
434
+ }
435
+
415
436
/**
416
437
* @hidden
417
438
*/
@@ -429,8 +450,9 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
429
450
430
451
let needClean = false ;
431
452
if ( changes ) {
453
+ var lastRecord = this . lastRecord ( ) + 1 ;
432
454
changes . forEachOperation ( ( item , _ , cindex ) => {
433
- if ( item . previousIndex != null || ( cindex < this . _recordSize ) ) {
455
+ if ( item . previousIndex != null || ( cindex < lastRecord ) ) {
434
456
needClean = true ;
435
457
}
436
458
} ) ;
@@ -443,10 +465,13 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
443
465
this . writeUpdate ( needClean ) ;
444
466
}
445
467
468
+ /**
469
+ * @hidden
470
+ */
446
471
readUpdate ( needClean : boolean ) {
447
472
if ( needClean ) {
448
473
// reset everything
449
- console . debug ( ` virtual-scroll, readUpdate: slow path` ) ;
474
+ console . debug ( ' virtual-scroll, readUpdate: slow path' ) ;
450
475
this . _cells . length = 0 ;
451
476
this . _nodes . length = 0 ;
452
477
this . _itmTmp . viewContainer . clear ( ) ;
@@ -458,8 +483,11 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
458
483
}
459
484
}
460
485
486
+ /**
487
+ * @hidden
488
+ */
461
489
writeUpdate ( needClean : boolean ) {
462
- console . debug ( ` virtual-scroll, writeUpdate` ) ;
490
+ console . debug ( ' virtual-scroll, writeUpdate need clean:' , needClean ) ;
463
491
const data = this . _data ;
464
492
const stopAtHeight = ( data . scrollTop + data . renderHeight ) ;
465
493
data . scrollDiff = SCROLL_DIFFERENCE_MINIMUM + 1 ;
@@ -475,6 +503,9 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
475
503
this . renderVirtual ( needClean ) ;
476
504
}
477
505
506
+ /**
507
+ * @hidden
508
+ */
478
509
private calcDimensions ( ) {
479
510
calcDimensions ( this . _data , this . _elementRef . nativeElement ,
480
511
this . approxItemWidth , this . approxItemHeight ,
@@ -571,7 +602,7 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
571
602
}
572
603
573
604
/**
574
- * @private
605
+ * @hidden
575
606
*/
576
607
resize ( ) {
577
608
// only continue if we've already initialized
@@ -605,7 +636,7 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
605
636
}
606
637
607
638
/**
608
- * @private
639
+ * @hidden
609
640
*/
610
641
private _stepChangeDetection ( ) {
611
642
// we need to do some change detection in this frame
@@ -624,7 +655,7 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
624
655
}
625
656
626
657
/**
627
- * @private
658
+ * @hidden
628
659
*/
629
660
private _stepNoChanges ( ) {
630
661
const data = this . _data ;
@@ -675,7 +706,7 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
675
706
}
676
707
677
708
/**
678
- * @private
709
+ * @hidden
679
710
*/
680
711
scrollUpdate ( ev : ScrollEvent ) {
681
712
// set the scroll top from the scroll event
@@ -718,6 +749,7 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
718
749
}
719
750
720
751
/**
752
+ * @hidden
721
753
* NO DOM
722
754
*/
723
755
private _listeners ( ) {
@@ -738,6 +770,7 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
738
770
}
739
771
740
772
/**
773
+ * @hidden
741
774
* DOM WRITE
742
775
*/
743
776
private _setHeight ( newVirtualHeight : number ) {
@@ -762,6 +795,9 @@ export class VirtualScroll implements DoCheck, AfterContentInit, OnDestroy {
762
795
}
763
796
}
764
797
798
+ /**
799
+ * @hidden
800
+ */
765
801
setElementClass ( className : string , add : boolean ) {
766
802
this . _renderer . setElementClass ( this . _elementRef . nativeElement , className , add ) ;
767
803
}
0 commit comments