summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.iOS
diff options
context:
space:
mode:
authorAdrian Knight <adrianknight89@outlook.com>2016-09-23 00:32:32 -0500
committerAdrian Knight <adrianknight89@outlook.com>2016-09-23 00:32:32 -0500
commita708ad9593c810b3100627d9d0bbc2eb2dd70246 (patch)
tree7652df60b022515cb2ba7c972b9b62a4ecbc952a /Xamarin.Forms.Platform.iOS
parent420ceb37d0d1d78dde17c717614c6874684a399e (diff)
downloadxamarin-forms-a708ad9593c810b3100627d9d0bbc2eb2dd70246.tar.gz
xamarin-forms-a708ad9593c810b3100627d9d0bbc2eb2dd70246.tar.bz2
xamarin-forms-a708ad9593c810b3100627d9d0bbc2eb2dd70246.zip
iOS ScrollView should not scroll out of place on scrolling to element
Diffstat (limited to 'Xamarin.Forms.Platform.iOS')
-rw-r--r--Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs
index 1e8ea1fc..bfb24337 100644
--- a/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs
+++ b/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs
@@ -208,6 +208,25 @@ namespace Xamarin.Forms.Platform.iOS
else
{
var positionOnScroll = Controller.GetScrollPositionForElement(e.Element as VisualElement, e.Position);
+
+ if (positionOnScroll.X < 0)
+ {
+ positionOnScroll.X = 0;
+ }
+ else if (positionOnScroll.X > ContentSize.Width - Bounds.Size.Width)
+ {
+ positionOnScroll.X = ContentSize.Width - Bounds.Size.Width;
+ }
+
+ if (positionOnScroll.Y < 0)
+ {
+ positionOnScroll.Y = 0;
+ }
+ else if (positionOnScroll.Y > ContentSize.Height - Bounds.Size.Height)
+ {
+ positionOnScroll.Y = ContentSize.Height - Bounds.Size.Height;
+ }
+
switch (ScrollView.Orientation)
{
case ScrollOrientation.Horizontal: