@@ -386,6 +386,8 @@ export class Virtualizer<
386386 private getScale = ( ) : number => {
387387 const virtualTotal = this . getTotalVirtualSize ( )
388388 const max = this . options . maxScrollSize
389+ // Invalid values disable scaling to keep math stable.
390+ if ( ! Number . isFinite ( max ) || max <= 0 ) return 1
389391 return virtualTotal > max ? virtualTotal / max : 1
390392 }
391393
@@ -786,7 +788,10 @@ export class Virtualizer<
786788 const scale = this . getScale ( )
787789 const tolerance = scale > 1 ? scale * 1.5 : 1.01
788790
789- if ( ! targetChanged && Math . abs ( targetOffset - this . getScrollOffset ( ) ) < tolerance ) {
791+ if (
792+ ! targetChanged &&
793+ Math . abs ( targetOffset - this . getScrollOffset ( ) ) < tolerance
794+ ) {
790795 this . scrollState . stableFrames ++
791796 if ( this . scrollState . stableFrames >= STABLE_FRAMES ) {
792797 // Final-pass exact landing. The reconcile-stable check uses a 1.01px
@@ -1676,7 +1681,11 @@ export class Virtualizer<
16761681 // can reconcile against subpixel rounding by the browser.
16771682 // _intendedScrollOffset is physical (compared against physical scrollTop readback).
16781683 this . _intendedScrollOffset = physicalOffset + ( physicalAdj ?? 0 )
1679- this . options . scrollToFn ( physicalOffset , { behavior, adjustments : physicalAdj } , this )
1684+ this . options . scrollToFn (
1685+ physicalOffset ,
1686+ { behavior, adjustments : physicalAdj } ,
1687+ this ,
1688+ )
16801689 }
16811690
16821691 measure = ( ) => {
0 commit comments