Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 1db2c08

Browse files
committed
Fix laggy scrolling when no horizontal scrollbar.
1 parent 9652a1d commit 1db2c08

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

src/GitHub.UI/Controls/ScollingVerticalStackPanel.cs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ public void SetVerticalOffset(double offset)
136136
}
137137
}
138138

139+
protected override void ParentLayoutInvalidated(UIElement child)
140+
{
141+
base.ParentLayoutInvalidated(child);
142+
}
143+
139144
protected override Size MeasureOverride(Size availableSize)
140145
{
141146
var maxWidth = 0.0;
@@ -155,6 +160,8 @@ protected override Size MeasureOverride(Size availableSize)
155160
ExtentWidth = maxWidth;
156161
ExtentHeight = height;
157162

163+
UpdateScrollInfo(new Size(maxWidth, height), new Size(ViewportWidth, ViewportHeight));
164+
158165
return new Size(
159166
Math.Min(maxWidth, availableSize.Width),
160167
Math.Min(height, availableSize.Height));
@@ -172,10 +179,23 @@ protected override Size ArrangeOverride(Size finalSize)
172179
y += child.DesiredSize.Height;
173180
}
174181

175-
ViewportWidth = finalSize.Width;
176-
ViewportHeight = finalSize.Height;
177-
ScrollOwner?.InvalidateScrollInfo();
182+
UpdateScrollInfo(new Size(ExtentWidth, ExtentHeight), finalSize);
178183
return finalSize;
179184
}
185+
186+
void UpdateScrollInfo(Size extent, Size viewport)
187+
{
188+
var changed = extent.Width != ExtentWidth ||
189+
extent.Height != ExtentHeight ||
190+
viewport.Width != ViewportWidth ||
191+
viewport.Height != ViewportHeight;
192+
193+
ExtentWidth = extent.Width;
194+
ExtentHeight = extent.Height;
195+
ViewportWidth = viewport.Width;
196+
ViewportHeight = viewport.Height;
197+
198+
if (changed) ScrollOwner?.InvalidateScrollInfo();
199+
}
180200
}
181201
}

0 commit comments

Comments
 (0)