@@ -372,7 +372,6 @@ export default {
372
372
let view
373
373
374
374
const continuous = startIndex <= this .$_endIndex && endIndex >= this .$_startIndex
375
- let unusedIndex
376
375
377
376
if (this .$_continuous !== continuous) {
378
377
if (continuous) {
@@ -407,9 +406,7 @@ export default {
407
406
}
408
407
}
409
408
410
- if (! continuous) {
411
- unusedIndex = new Map ()
412
- }
409
+ let unusedIndex = continuous ? null : new Map ();
413
410
414
411
let item, type, unusedPool
415
412
let v
@@ -429,9 +426,9 @@ export default {
429
426
// No view assigned to item
430
427
if (! view) {
431
428
type = item[typeField]
429
+ unusedPool = unusedViews .get (type)
432
430
433
431
if (continuous) {
434
- unusedPool = unusedViews .get (type)
435
432
// Reuse existing view
436
433
if (unusedPool && unusedPool .length ) {
437
434
view = unusedPool .pop ()
@@ -444,23 +441,21 @@ export default {
444
441
view = this .addView (pool, i, item, key, type)
445
442
}
446
443
} else {
447
- unusedPool = unusedViews .get (type)
448
- v = unusedIndex .get (type) || 0
449
- // Use existing view
450
- // We don't care if they are already used
451
- // because we are not in continous scrolling
452
- if (unusedPool && v < unusedPool .length ) {
453
- view = unusedPool[v]
454
- view .item = item
455
- view .nr .used = true
456
- view .nr .index = i
457
- view .nr .key = key
458
- view .nr .type = type
459
- unusedIndex .set (type, v + 1 )
460
- } else {
444
+ if (! unusedPool || v >= unusedPool .length ) {
461
445
view = this .addView (pool, i, item, key, type)
462
446
this .unuseView (view, true )
463
447
}
448
+ // Use existing view
449
+ // We don't care if they are already used
450
+ // because we are not in continous scrolling
451
+ v = unusedIndex .get (type) || 0
452
+ view = unusedPool[v]
453
+ view .item = item
454
+ view .nr .used = true
455
+ view .nr .index = i
456
+ view .nr .key = key
457
+ view .nr .type = type
458
+ unusedIndex .set (type, v + 1 )
464
459
v++
465
460
}
466
461
views .set (key, view)
0 commit comments