diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2016-10-04 09:34:35 +0200 |
---|---|---|
committer | Stephane Delcroix <stephane@delcroix.org> | 2016-10-04 09:34:35 +0200 |
commit | d34dcf2cbc9dec01c806b64707bbf99c8c58cc8a (patch) | |
tree | b4ff299bb257ddd47f06ef8289b17b31d8bd96db | |
parent | bd195ffe10e713393b9eaaff4f0720227e3ea9c9 (diff) | |
parent | e9606cd6e2bbe60b20d189682c2527751555820a (diff) | |
download | xamarin-forms-d34dcf2cbc9dec01c806b64707bbf99c8c58cc8a.tar.gz xamarin-forms-d34dcf2cbc9dec01c806b64707bbf99c8c58cc8a.tar.bz2 xamarin-forms-d34dcf2cbc9dec01c806b64707bbf99c8c58cc8a.zip |
Merge branch 'ios-scrolltoposition' of https://github.com/adrianknight89/Xamarin.Forms into adrianknight89-ios-scrolltoposition
3 files changed, 54 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44461.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44461.cs new file mode 100644 index 00000000..c0937a8f --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44461.cs @@ -0,0 +1,49 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +namespace Xamarin.Forms.Controls +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 44461, "ScrollToPosition.Center works differently on Android and iOS", PlatformAffected.iOS)] + public class Bugzilla44461 : TestContentPage + { + protected override void Init() + { + var grid = new Grid + { + RowSpacing = 0, + }; + + var scrollView = new ScrollView + { + Orientation = ScrollOrientation.Horizontal, + VerticalOptions = LayoutOptions.Center, + BackgroundColor = Color.Yellow, + HeightRequest = 50 + }; + grid.Children.Add(scrollView); + + var stackLayout = new StackLayout + { + Orientation = StackOrientation.Horizontal, + Spacing = 20 + }; + + for (var i = 0; i < 10; i++) + { + var button = new Button + { + Text = "Button" + i + }; + button.Clicked += (sender, args) => + { + scrollView.ScrollToAsync(sender as Button, ScrollToPosition.Center, true); + }; + + stackLayout.Children.Add(button); + } + scrollView.Content = stackLayout; + Content = grid; + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 670f286c..6a930442 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -125,6 +125,7 @@ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla42364.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla42519.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla43516.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)Bugzilla44461.cs" /> <Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Bugzilla34727.cs" /> diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs index b2107db7..3d38bb6b 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/ScrollViewRenderer.cs @@ -196,6 +196,10 @@ namespace Xamarin.Forms.Platform.iOS else { var positionOnScroll = Controller.GetScrollPositionForElement(e.Element as VisualElement, e.Position); + + positionOnScroll.X = positionOnScroll.X.Clamp(0, ContentSize.Width - Bounds.Size.Width); + positionOnScroll.Y = positionOnScroll.Y.Clamp(0, ContentSize.Height - Bounds.Size.Height); + switch (ScrollView.Orientation) { case ScrollOrientation.Horizontal: |