Skip to content

Commit d149662

Browse files
committed
fix: WASM ScrollContentPresenter offsets are immediately set after scroll request without animation
1 parent 01205a1 commit d149662

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Uno.UI/UI/Xaml/Controls/ScrollContentPresenter/ScrollContentPresenter.wasm.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ public void ScrollTo(double? horizontalOffset, double? verticalOffset, bool disa
197197

198198
if (_pendingScrollTo.HasValue)
199199
{
200+
if (disableAnimation)
201+
{
202+
// Ensure offset values match native ones if animation is disabled
203+
// as the scroll event may occur only asynchronously
204+
// while the values are already set properly.
205+
HorizontalOffset = GetNativeHorizontalOffset();
206+
VerticalOffset = GetNativeVerticalOffset();
207+
ScrollOffsets = new Point(HorizontalOffset, VerticalOffset);
208+
}
209+
200210
// The scroll to was not processed by the native SCP, we need to re-request ScrollTo a bit later.
201211
// This happen has soon as the native SCP element is not in a valid state (like un-arranged or hidden).
202212

@@ -226,7 +236,7 @@ public void ScrollTo(double? horizontalOffset, double? verticalOffset, bool disa
226236
horizontalOffset ?? nativeHorizontalOffset,
227237
verticalOffset ?? nativeVerticalOffset,
228238
isIntermediate: false
229-
);
239+
);
230240
}
231241
}
232242
}

0 commit comments

Comments
 (0)