@@ -317,40 +317,43 @@ export function updateDimensions(plt: Platform, nodes: VirtualNode[], cells: Vir
317
317
data . topViewCell = totalCells ;
318
318
data . bottomViewCell = 0 ;
319
319
320
- // completely realign position to ensure they're all accurately placed
321
- cell = cells [ 0 ] ;
322
- previousCell = {
323
- row : 0 ,
324
- width : 0 ,
325
- height : 0 ,
326
- top : cell . top ,
327
- left : 0 ,
328
- tmpl : - 1
329
- } ;
330
- for ( var i = 0 ; i < totalCells ; i ++ ) {
331
- cell = cells [ i ] ;
332
-
333
- if ( previousCell . left + previousCell . width + cell . width > data . viewWidth ) {
334
- // new row
335
- cell . row ++ ;
336
- cell . top = ( previousCell . top + previousCell . height ) ;
337
- cell . left = 0 ;
338
-
339
- } else {
340
- // same row
341
- cell . row = previousCell . row ;
342
- cell . top = previousCell . top ;
343
- cell . left = ( previousCell . left + previousCell . width ) ;
344
- }
320
+ if ( totalCells > 0 ) {
321
+ // completely realign position to ensure they're all accurately placed
322
+ cell = cells [ 0 ] ;
323
+ previousCell = {
324
+ row : 0 ,
325
+ width : 0 ,
326
+ height : 0 ,
327
+ top : cell . top ,
328
+ left : 0 ,
329
+ tmpl : - 1
330
+ } ;
331
+
332
+ for ( var i = 0 ; i < totalCells ; i ++ ) {
333
+ cell = cells [ i ] ;
345
334
346
- // figure out which cells are viewable within the viewport
347
- if ( cell . top + cell . height > data . scrollTop && i < data . topViewCell ) {
348
- data . topViewCell = i ;
335
+ if ( previousCell . left + previousCell . width + cell . width > data . viewWidth ) {
336
+ // new row
337
+ cell . row ++ ;
338
+ cell . top = ( previousCell . top + previousCell . height ) ;
339
+ cell . left = 0 ;
340
+
341
+ } else {
342
+ // same row
343
+ cell . row = previousCell . row ;
344
+ cell . top = previousCell . top ;
345
+ cell . left = ( previousCell . left + previousCell . width ) ;
346
+ }
347
+
348
+ // figure out which cells are viewable within the viewport
349
+ if ( cell . top + cell . height > data . scrollTop && i < data . topViewCell ) {
350
+ data . topViewCell = i ;
349
351
350
- } else if ( cell . top < viewableBottom && i > data . bottomViewCell ) {
351
- data . bottomViewCell = i ;
352
+ } else if ( cell . top < viewableBottom && i > data . bottomViewCell ) {
353
+ data . bottomViewCell = i ;
354
+ }
355
+ previousCell = cell ;
352
356
}
353
- previousCell = cell ;
354
357
}
355
358
356
359
}
0 commit comments