* added test for issue4854 * fix issue4854
This commit is contained in:
Родитель
0918df146d
Коммит
77c7066c89
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
#if UITEST
|
||||
using NUnit.Framework;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 4854, "[macOS] Visual glitch when exiting the full screen with ScrollViewer", PlatformAffected.macOS)]
|
||||
public class Issue4854 : TestContentPage
|
||||
{
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
var gMain = new Grid { BackgroundColor = Color.LightBlue };
|
||||
gMain.RowDefinitions.Add(new RowDefinition { Height = GridLength.Star });
|
||||
gMain.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
|
||||
var label = new Label
|
||||
{
|
||||
Text = "Enter full screen and exit and see the artifacts on the screen.",
|
||||
FontSize = 14
|
||||
};
|
||||
var sl = new StackLayout { HorizontalOptions = LayoutOptions.Center, WidthRequest = 300, Padding = new Thickness(15) };
|
||||
sl.Children.Add(label);
|
||||
gMain.Children.Add(sl);
|
||||
|
||||
var button = new Button { Text = "Test", BackgroundColor = Color.Gray, HorizontalOptions = LayoutOptions.Center };
|
||||
var g = new Grid { BackgroundColor = Color.LightGray, Padding = new Thickness(20) };
|
||||
g.Children.Add(button);
|
||||
Grid.SetRow(g, 1);
|
||||
gMain.Children.Add(g);
|
||||
|
||||
Content = new ScrollView { Content = gMain, BackgroundColor = Color.LightGreen };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1094,6 +1094,7 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Issue4356.cs">
|
||||
<DependentUpon>Issue4356.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue4854.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue5951.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Github6021.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Issue5132.cs" />
|
||||
|
|
|
@ -255,7 +255,7 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
if (ContentView == null || ScrollView == null || ScrollView.Content == null)
|
||||
return false;
|
||||
|
||||
if (Math.Abs(ScrollView.ScrollY) < 0.001 && Math.Abs(ScrollView.ScrollX) < 0.001 && ScrollView.Content.Height > ScrollView.Height)
|
||||
if (Math.Abs(ScrollView.ScrollY) < 0.001 && Math.Abs(ScrollView.ScrollX) < 0.001 && ScrollView.Content.Height >= ScrollView.Height)
|
||||
{
|
||||
ContentView.ScrollToPoint(new CoreGraphics.CGPoint(0, 0));
|
||||
return true;
|
||||
|
@ -270,12 +270,16 @@ namespace Xamarin.Forms.Platform.MacOS
|
|||
if (ScrollView == null)
|
||||
return;
|
||||
|
||||
if (ScrollView.ContentSize.Height >= ScrollView.Height)
|
||||
var height = ScrollView.Height;
|
||||
var contentHeightOverflow = ScrollView.ContentSize.Height - height;
|
||||
if (contentHeightOverflow >= 0)
|
||||
{
|
||||
CoreGraphics.CGPoint location = ContentView.DocumentVisibleRect().Location;
|
||||
|
||||
if (location.Y > -1 && ScrollView.Height >= 0)
|
||||
ScrollView.SetScrolledPosition(Math.Max(0, location.X), Math.Max(0, ScrollView.ContentSize.Height - ScrollView.Height - location.Y));
|
||||
if (height >= 0)
|
||||
{
|
||||
var location = ContentView.DocumentVisibleRect().Location;
|
||||
if (location.Y > -1)
|
||||
ScrollView.SetScrolledPosition(Math.Max(0, location.X), Math.Max(0, contentHeightOverflow - location.Y));
|
||||
}
|
||||
}
|
||||
else
|
||||
ResetNativeNonScroll();
|
||||
|
|
Загрузка…
Ссылка в новой задаче