Skip to content

Commit

Permalink
fix: Fix possible scroll to out of bounds of the SV on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Jun 2, 2021
1 parent ba767c5 commit d1f0296
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 9 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,17 @@ private bool ChangeViewNative(double? horizontalOffset, double? verticalOffset,
var success = desiredOffsets == clampedOffsets;
if (!success && IsArrangeDirty)
{
// If the the requested offsets are out-of - bounds, but we actually does have our final bounds yet,
// we allow to set the desired offsets. If needed, they will then be clamped by the OnAfterArrange().
// This is needed to allow a ScrollTo before the SV has been layouted.

_pendingChangeView = (horizontalOffset, verticalOffset, disableAnimation);
_scrollableContainer.SetContentOffset(desiredOffsets, !disableAnimation);
}
else
{
_scrollableContainer.SetContentOffset(clampedOffsets, !disableAnimation);
}

_scrollableContainer.SetContentOffset(desiredOffsets, !disableAnimation);

if(zoomFactor is { } zoom)
{
Expand Down
6 changes: 1 addition & 5 deletions src/Uno.UI/UI/Xaml/UIElement.debugging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@
using Windows.UI.Core;
using System.Text;

#if __IOS__
using UIKit;
#endif

#if XAMARIN_ANDROID
using View = Android.Views.View;
using ViewGroup = Android.Views.ViewGroup;
using Font = Android.Graphics.Typeface;
using Android.Graphics;
using DependencyObject = System.Object;
#elif XAMARIN_IOS
#elif __IOS__
using View = UIKit.UIView;
using ViewGroup = UIKit.UIView;
using UIKit;
Expand Down

0 comments on commit d1f0296

Please sign in to comment.