From cd22048d017dcf5266dd9a6807d0078521437b2b Mon Sep 17 00:00:00 2001 From: grokys Date: Wed, 26 Aug 2026 20:06:58 +0200 Subject: [PATCH] Remove the `isScrollIntoView` parameter. --- src/Avalonia.Controls/VirtualizingStackPanel.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Avalonia.Controls/VirtualizingStackPanel.cs b/src/Avalonia.Controls/VirtualizingStackPanel.cs index 63e46b4c1b..e78643ef82 100644 --- a/src/Avalonia.Controls/VirtualizingStackPanel.cs +++ b/src/Avalonia.Controls/VirtualizingStackPanel.cs @@ -653,7 +653,7 @@ namespace Avalonia.Controls scrollToElement.Measure(Size.Infinity); // Get the expected position of the element and put it in place. - var anchorU = GetOrEstimateElementU(index, isScrollIntoView: true); + var anchorU = GetOrEstimateElementU(index); var rect = Orientation == Orientation.Horizontal ? new Rect(anchorU, 0, scrollToElement.DesiredSize.Width, scrollToElement.DesiredSize.Height) : new Rect(0, anchorU, scrollToElement.DesiredSize.Width, scrollToElement.DesiredSize.Height); @@ -885,7 +885,7 @@ namespace Avalonia.Controls position = startIndex * estimatedSize; } - private double GetOrEstimateElementU(int index, bool isScrollIntoView = false) + private double GetOrEstimateElementU(int index) { // Return the position of the existing element if realized. var u = _realizedElements?.GetElementU(index) ?? double.NaN; @@ -904,15 +904,10 @@ namespace Avalonia.Controls if (index < first) { - if (isScrollIntoView && first > 0) - { - // When scrolling a preceding item into view, interpolate between the known - // panel origin and the first realized item. Using the realized items' average - // size to extrapolate backwards can place the target before the panel origin. - return realized.StartU * index / first; - } - - return realized.StartU - ((first - index) * estimatedSize); + // Interpolate between the known panel origin and the first realized item. + // Using the realized items' average size to extrapolate backwards can place + // the target before the panel origin. + return realized.StartU * index / first; } if (index > last)