@@ -17,6 +17,7 @@ export function processRecords(stopAtHeight: number,
17
17
records : any [ ] , cells : VirtualCell [ ] ,
18
18
headerFn : Function , footerFn : Function ,
19
19
data : VirtualData ) {
20
+ console . debug ( 'virtual-util-processRecords' , 'cells before processing are:' , cells ) ;
20
21
let record : any ;
21
22
let startRecordIndex : number ;
22
23
let previousCell : VirtualCell ;
@@ -79,6 +80,7 @@ export function processRecords(stopAtHeight: number,
79
80
if ( previousCell . top + previousCell . height + data . itmHeight > stopAtHeight && processedTotal > 3 ) {
80
81
return ;
81
82
}
83
+ console . debug ( 'virtual-util-processRecords' , 'cells after processing are:' , cells ) ;
82
84
}
83
85
}
84
86
@@ -464,7 +466,11 @@ export function adjustRendered(cells: VirtualCell[], data: VirtualData) {
464
466
data . topCell = Math . max ( data . topViewCell - viewableRenderedPadding , 0 ) ;
465
467
data . bottomCell = Math . min ( data . topCell + 2 , totalCells - 1 ) ;
466
468
467
- for ( var i = data . topCell ; i < totalCells ; i ++ ) {
469
+ console . debug ( 'virtualScroll-util' , 'before scrolling down, will render cells:' , data . topCell , 'to' , data . bottomCell ,
470
+ 'totalCells are:' , totalCells , 'renderHeight is now' , cellsRenderHeight , 'viewableRenderedPadding' , viewableRenderedPadding ,
471
+ 'topViewCell:' , data . topViewCell , 'bottomViewCell:' , data . bottomViewCell ) ;
472
+
473
+ for ( let i = data . topCell ; i < totalCells ; i ++ ) {
468
474
cell = cells [ i ] ;
469
475
if ( cell . row !== lastRow ) {
470
476
cellsRenderHeight += cell . height ;
@@ -480,6 +486,29 @@ export function adjustRendered(cells: VirtualCell[], data: VirtualData) {
480
486
}
481
487
}
482
488
489
+ if ( data . bottomCell === totalCells - 1 ) {
490
+ let tempHeight = 0 ;
491
+ lastRow = - 1 ;
492
+ for ( let i = data . bottomCell ; i >= 0 ; i -- ) {
493
+ cell = cells [ i ] ;
494
+ if ( cell . row !== lastRow ) {
495
+ tempHeight += cell . height ;
496
+ lastRow = cell . row ;
497
+ }
498
+
499
+ if ( i < data . topCell ) {
500
+ data . topCell = i ;
501
+ }
502
+
503
+ if ( tempHeight >= maxRenderHeight ) {
504
+ break ;
505
+ }
506
+ }
507
+ }
508
+ console . debug ( 'virtualScroll-util' , 'after scrolling down, will render cells:' , data . topCell , 'to' , data . bottomCell ,
509
+ 'totalCells are:' , totalCells , 'renderHeight is now' , cellsRenderHeight , 'viewableRenderedPadding' , viewableRenderedPadding ,
510
+ 'topViewCell:' , data . topViewCell , 'bottomViewCell:' , data . bottomViewCell ) ;
511
+
483
512
} else {
484
513
// scroll up
485
514
data . bottomCell = Math . min ( data . bottomViewCell + viewableRenderedPadding , totalCells - 1 ) ;
@@ -500,6 +529,29 @@ export function adjustRendered(cells: VirtualCell[], data: VirtualData) {
500
529
break ;
501
530
}
502
531
}
532
+
533
+ if ( data . topCell === 0 ) {
534
+ let tempHeight = 0 ;
535
+ lastRow = - 1 ;
536
+ for ( let i = data . topCell ; i < totalCells ; i ++ ) {
537
+ cell = cells [ i ] ;
538
+ if ( cell . row !== lastRow ) {
539
+ tempHeight += cell . height ;
540
+ lastRow = cell . row ;
541
+ }
542
+
543
+ if ( i > data . bottomCell ) {
544
+ data . bottomCell = i ;
545
+ }
546
+
547
+ if ( tempHeight >= maxRenderHeight ) {
548
+ break ;
549
+ }
550
+ }
551
+ }
552
+ console . debug ( 'virtualScroll-util' , 'scrolling up, will render cells:' , data . topCell , 'to' , data . bottomCell ,
553
+ 'totalCells are:' , totalCells , 'renderHeight is now' , cellsRenderHeight , 'viewableRenderedPadding' , viewableRenderedPadding ,
554
+ 'topViewCell:' , data . topViewCell , 'bottomViewCell:' , data . bottomViewCell ) ;
503
555
}
504
556
}
505
557
0 commit comments