1
1
import { EmbeddedViewRef , TemplateRef , ViewContainerRef } from '@angular/core' ;
2
+ import { assert } from '../../util/util' ;
2
3
3
4
import { Platform } from '../../platform/platform' ;
4
5
@@ -17,7 +18,6 @@ export function processRecords(stopAtHeight: number,
17
18
records : any [ ] , cells : VirtualCell [ ] ,
18
19
headerFn : Function , footerFn : Function ,
19
20
data : VirtualData ) {
20
- console . debug ( 'virtual-util-processRecords' , 'cells before processing are:' , cells ) ;
21
21
let record : any ;
22
22
let startRecordIndex : number ;
23
23
let previousCell : VirtualCell ;
@@ -80,7 +80,6 @@ export function processRecords(stopAtHeight: number,
80
80
if ( previousCell . top + previousCell . height + data . itmHeight > stopAtHeight && processedTotal > 3 ) {
81
81
return ;
82
82
}
83
- console . debug ( 'virtual-util-processRecords' , 'cells after processing are:' , cells ) ;
84
83
}
85
84
}
86
85
@@ -137,15 +136,14 @@ export function populateNodeData(startCellIndex: number, endCellIndex: number, s
137
136
startCellIndex = Math . max ( startCellIndex , 0 ) ;
138
137
endCellIndex = Math . min ( endCellIndex , cells . length - 1 ) ;
139
138
140
- const usedNodes : any [ ] = [ ] ;
139
+ const usedNodes : VirtualNode [ ] = [ ] ;
141
140
for ( var cellIndex = startCellIndex ; cellIndex <= endCellIndex ; cellIndex ++ ) {
142
141
cell = cells [ cellIndex ] ;
143
142
availableNode = null ;
144
143
145
144
// find the first one that's available
146
145
const existingNode = nodes . find ( n => n . cell === cellIndex && n . tmpl === cell . tmpl ) ;
147
146
if ( existingNode ) {
148
- console . debug ( 'virtual-util' , 'found that cell is already rendered in existingNode' , existingNode ) ;
149
147
if ( existingNode . view . context . $implicit === records [ cell . record ] ) {
150
148
usedNodes . push ( existingNode ) ;
151
149
continue ; // optimization: node data is the same no need to update
@@ -241,6 +239,8 @@ export function populateNodeData(startCellIndex: number, endCellIndex: number, s
241
239
const removeIndex = nodes . findIndex ( n => n === node ) ;
242
240
nodes . splice ( removeIndex , 1 ) ;
243
241
} ) ;
242
+ usedNodes . length = 0 ;
243
+ unusedNodes . length = 0 ;
244
244
245
245
return hasChanges ;
246
246
}
@@ -338,7 +338,6 @@ export function updateDimensions(plt: Platform, nodes: VirtualNode[], cells: Vir
338
338
cell . row ++ ;
339
339
cell . top = ( previousCell . top + previousCell . height ) ;
340
340
cell . left = 0 ;
341
-
342
341
} else {
343
342
// same row
344
343
cell . row = previousCell . row ;
@@ -356,7 +355,6 @@ export function updateDimensions(plt: Platform, nodes: VirtualNode[], cells: Vir
356
355
previousCell = cell ;
357
356
}
358
357
}
359
-
360
358
}
361
359
362
360
@@ -477,6 +475,7 @@ export function adjustRendered(cells: VirtualCell[], data: VirtualData) {
477
475
data . topCell = data . bottomCell ;
478
476
479
477
let cellsRenderHeight = 0 ;
478
+ assert ( data . bottomCell > 0 , 'bottomCell should be greater than 0' ) ;
480
479
for ( let i = data . bottomCell ; i >= 0 ; i -- ) {
481
480
cellsRenderHeight += cells [ i ] . height ;
482
481
if ( i < data . topCell ) data . topCell = i ;
0 commit comments