@@ -180,9 +180,6 @@ export class IronListAdapter {
180180    this . _resizeHandler ( ) ; 
181181    flush ( ) ; 
182182    this . _scrollHandler ( ) ; 
183-     if  ( this . __physicalSizesChangedDebouncer )  { 
184-       this . __physicalSizesChangedDebouncer . flush ( ) ; 
185-     } 
186183    if  ( this . __fixInvalidItemPositioningDebouncer )  { 
187184      this . __fixInvalidItemPositioningDebouncer . flush ( ) ; 
188185    } 
@@ -231,16 +228,15 @@ export class IronListAdapter {
231228    const  prevAvgCount  =  this . _physicalAverageCount ; 
232229    const  prevPhysicalAvg  =  this . _physicalAverage ; 
233230
234-     let  physicalSizesChanged  =  false ; 
235231    // eslint-disable-next-line @typescript-eslint/no-unused-vars 
236232    this . _iterateItems ( ( pidx ,  vidx )  =>  { 
237233      oldPhysicalSize  +=  this . _physicalSizes [ pidx ] ; 
238-       const  elementOldPhysicalSize  =  this . _physicalSizes [ pidx ]   ||   0 ; 
234+       const  elementOldPhysicalSize  =  this . _physicalSizes [ pidx ] ; 
239235      this . _physicalSizes [ pidx ]  =  Math . ceil ( this . __getBorderBoxHeight ( this . _physicalItems [ pidx ] ) ) ; 
240236
241237      if  ( this . _physicalSizes [ pidx ]  !==  elementOldPhysicalSize )  { 
242238        // Physical size changed, but resize observer may not catch it if the original size is restored quickly. 
243-         physicalSizesChanged   =   true ; 
239+         this . __schedulePhysicalSizesChangedDebouncer ( ) ; 
244240      } 
245241
246242      newPhysicalSize  +=  this . _physicalSizes [ pidx ] ; 
@@ -255,13 +251,27 @@ export class IronListAdapter {
255251        ( prevPhysicalAvg  *  prevAvgCount  +  newPhysicalSize )  /  this . _physicalAverageCount , 
256252      ) ; 
257253    } 
254+   } 
258255
259-     if  ( physicalSizesChanged )  { 
260-       // There were changes in physical sizes, schedule a resize handler call 
261-       this . __physicalSizesChangedDebouncer  =  Debouncer . debounce ( this . __physicalSizesChangedDebouncer ,  microTask ,  ( )  =>  { 
262-         this . _resizeHandler ( ) ; 
263-       } ) ; 
264-     } 
256+   __schedulePhysicalSizesChangedDebouncer ( )  { 
257+     this . __physicalSizesChangedDebouncer  =  Debouncer . debounce ( 
258+       this . __physicalSizesChangedDebouncer , 
259+       animationFrame , 
260+       ( )  =>  { 
261+         if  ( this . __hasSizeChanges ( ) )  { 
262+           this . _updateMetrics ( ) ; 
263+           this . _positionItems ( ) ; 
264+           this . _updateScrollerSize ( ) ; 
265+         } 
266+       } , 
267+     ) ; 
268+   } 
269+ 
270+   __hasSizeChanges ( )  { 
271+     return  this . _physicalItems ?. some ( ( item ,  pidx )  =>  { 
272+       const  currentSize  =  Math . ceil ( this . __getBorderBoxHeight ( item ) ) ; 
273+       return  currentSize  !==  this . _physicalSizes [ pidx ] ; 
274+     } ) ; 
265275  } 
266276
267277  __getBorderBoxHeight ( el )  { 
@@ -646,11 +656,6 @@ export class IronListAdapter {
646656  _resizeHandler ( )  { 
647657    super . _resizeHandler ( ) ; 
648658
649-     if  ( this . __physicalSizesChangedDebouncer  &&  this . __physicalSizesChangedDebouncer . isActive ( ) )  { 
650-       // Cancel any pending debounced calls to avoid unnecessary extra work 
651-       this . __physicalSizesChangedDebouncer . cancel ( ) ; 
652-     } 
653- 
654659    // Fixes an issue where the new items are not created on scroll target resize when the scroll position is around the end. 
655660    // See https://github.com/vaadin/flow-components/issues/7307 
656661    const  lastIndexVisible  =  this . adjustedLastVisibleIndex  ===  this . size  -  1 ; 
0 commit comments