From e0b48e11f6a83884f833731877fdb46834e6aa02 Mon Sep 17 00:00:00 2001 From: xiaoy312 Date: Wed, 22 Feb 2023 08:40:08 -0500 Subject: [PATCH] fix(ListView): ios lv snap rubber-banding --- .../UITests.Shared/UITests.Shared.projitems | 9 +- .../ListView/ListView_Snap_Rubberband.xaml | 98 +++++++++++++++++++ .../ListView/ListView_Snap_Rubberband.xaml.cs | 35 +++++++ .../Controls/ScrollViewer/ScrollViewer.cs | 1 + 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Snap_Rubberband.xaml create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Snap_Rubberband.xaml.cs diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index c7fdb2ec8d01..9c6624bd5d07 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -1558,6 +1558,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -5532,6 +5536,9 @@ Image_Source_Nullify.xaml + + ListView_Snap_Rubberband.xaml + TextBox_PlaceholderForeground.xaml @@ -8842,4 +8849,4 @@ - \ No newline at end of file + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Snap_Rubberband.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Snap_Rubberband.xaml new file mode 100644 index 000000000000..33849c1744fc --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Snap_Rubberband.xaml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Snap_Rubberband.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Snap_Rubberband.xaml.cs new file mode 100644 index 000000000000..afc5a24f00f0 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/ListView/ListView_Snap_Rubberband.xaml.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; +using Uno.UI.Samples.Controls; +using Uno.UI.Samples.Tests; +using Uno.UI.Samples.UITests.Helpers; + +namespace SamplesApp.Windows_UI_Xaml_Controls.ListView +{ + [SampleControlInfo("AAAListView", nameof(ListView_Snap_Rubberband), IsManualTest = true, Description = SampleDescription)] + public sealed partial class ListView_Snap_Rubberband : UserControl + { + private const string SampleDescription = + "[ManualTest]: While the LV is snapped to the 1st item, wait at least 1second. " + + "Using flipping gesture, over-scroll to left, and then quickly (within 250ms) scroll to the right. " + + "The LV should snap to the 2nd item, and not rubber banding back to the first."; + + public ListView_Snap_Rubberband() + { + this.InitializeComponent(); + this.DataContext = new[] { 0, 1, 2 }; + } + } +} diff --git a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs index f2cf515b85fc..a66211bb6bca 100644 --- a/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs +++ b/src/Uno.UI/UI/Xaml/Controls/ScrollViewer/ScrollViewer.cs @@ -1280,6 +1280,7 @@ internal void OnPresenterScrolled(double horizontalOffset, double verticalOffset if (isIntermediate && UpdatesMode != Uno.UI.Xaml.Controls.ScrollViewerUpdatesMode.Synchronous) { RequestUpdate(); + _snapPointsTimer?.Stop(); } else {