@@ -324,6 +324,7 @@ export class DomRepeat extends domRepeatBase {
324
324
this . __itemsArrayChanged = false ;
325
325
this . __shouldMeasureChunk = false ;
326
326
this . __shouldContinueChunking = false ;
327
+ this . __chunkingId = 0 ;
327
328
this . __sortFn = null ;
328
329
this . __filterFn = null ;
329
330
this . __observePaths = null ;
@@ -550,7 +551,8 @@ export class DomRepeat extends domRepeatBase {
550
551
// pre-empt this measurement.
551
552
if ( this . initialCount &&
552
553
( this . __shouldMeasureChunk || this . __shouldContinueChunking ) ) {
553
- this . __debounceRender ( this . __continueChunkingAfterRaf ) ;
554
+ cancelAnimationFrame ( this . __chunkingId ) ;
555
+ this . __chunkingId = requestAnimationFrame ( ( ) => this . __continueChunking ( ) ) ;
554
556
}
555
557
// Set rendered item count
556
558
this . _setRenderedItemCount ( this . __instances . length ) ;
@@ -583,6 +585,7 @@ export class DomRepeat extends domRepeatBase {
583
585
584
586
__calculateLimit ( filteredItemCount ) {
585
587
let limit = filteredItemCount ;
588
+ const currentCount = this . __instances . length ;
586
589
// When chunking, we increase the limit from the currently rendered count
587
590
// by the chunk count that is re-calculated after each rAF (with special
588
591
// cases for reseting the limit to initialCount after changing items)
@@ -594,18 +597,18 @@ export class DomRepeat extends domRepeatBase {
594
597
limit = Math . min ( filteredItemCount , this . initialCount ) ;
595
598
// Subtract off any existing instances to determine the number of
596
599
// instances that will be created
597
- newCount = Math . max ( limit - this . renderedItemCount , 0 ) ;
600
+ newCount = Math . max ( limit - currentCount , 0 ) ;
598
601
// Initialize the chunk size with how many items we're creating
599
602
this . __chunkCount = newCount || 1 ;
600
603
} else {
601
604
// The number of new instances that will be created is based on the
602
605
// existing instances, the new list size, and the chunk size
603
606
newCount = Math . min (
604
- Math . max ( filteredItemCount - this . renderedItemCount , 0 ) ,
607
+ Math . max ( filteredItemCount - currentCount , 0 ) ,
605
608
this . __chunkCount ) ;
606
609
// Update the limit based on how many new items we're making, limited
607
610
// buy the total size of the list
608
- limit = Math . min ( this . renderedItemCount + newCount , filteredItemCount ) ;
611
+ limit = Math . min ( currentCount + newCount , filteredItemCount ) ;
609
612
}
610
613
// Record some state about chunking for use in `__continueChunking`
611
614
this . __shouldMeasureChunk = newCount === this . __chunkCount ;
@@ -616,10 +619,6 @@ export class DomRepeat extends domRepeatBase {
616
619
return limit ;
617
620
}
618
621
619
- __continueChunkingAfterRaf ( ) {
620
- requestAnimationFrame ( ( ) => this . __continueChunking ( ) ) ;
621
- }
622
-
623
622
__continueChunking ( ) {
624
623
// Simple auto chunkSize throttling algorithm based on feedback loop:
625
624
// measure actual time between frames and scale chunk count by ratio of
0 commit comments