Skip to content

Commit

Permalink
Merge pull request #18891 from unoplatform/mergify/bp/release/stable/…
Browse files Browse the repository at this point in the history
…5.5/pr-18883

fix(scrollviewer): fix scrollArgs.IsIntermediate on WASm (backport #18883)
  • Loading branch information
jeromelaban authored Nov 22, 2024
2 parents 4e1bbc6 + e180934 commit 62f1f40
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -2466,6 +2466,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_IsIntermediate.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_Content_Smaller_Than_Viewport.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -9517,6 +9521,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_Simple.xaml.cs">
<DependentUpon>ScrollViewer_Simple.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_IsIntermediate.xaml.cs">
<DependentUpon>ScrollViewer_IsIntermediate.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ScrollViewerTests\ScrollViewer_Content_Smaller_Than_Viewport.xaml.cs">
<DependentUpon>ScrollViewer_Content_Smaller_Than_Viewport.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Page x:Class="UITests.Windows_UI_Xaml_Controls.ScrollViewerTests.ScrollViewer_IsIntermediate"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Windows_UI_Xaml_Controls.ScrollViewerTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<StackPanel>
<TextBlock>
Repro steps:
<LineBreak />
1. Scroll the ScrollViewer below using the scroll bar. You should see the status below possibly change to "Last ScrollViewerViewChangedEventArgs.IsIntermediate = true" but then it must end up on "Last ScrollViewerViewChangedEventArgs.IsIntermediate = false"
<LineBreak />
2. Scroll the ScrollViewer below using the mouse wheel. You should see the status below possibly change to "Last ScrollViewerViewChangedEventArgs.IsIntermediate = true" but then it must end up on "Last ScrollViewerViewChangedEventArgs.IsIntermediate = false"
</TextBlock>
<ScrollViewer Height="400" Width="400" ViewChanged="ScrollViewer_ViewChanged">
<Border Height="800" Width="800" Background="LightBlue" BorderBrush="Black" BorderThickness="2">
<TextBlock Text="Scroll me" />
</Border>
</ScrollViewer>
<TextBlock x:Name="statusTb" Text="Last ScrollViewerViewChangedEventArgs.IsIntermediate = N/A" />
</StackPanel>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Microsoft.UI.Xaml.Controls;
using Uno.UI.Samples.Controls;

namespace UITests.Windows_UI_Xaml_Controls.ScrollViewerTests
{
[Sample("Scrolling", IsManualTest = true)]
public sealed partial class ScrollViewer_IsIntermediate : Page
{
public ScrollViewer_IsIntermediate()
{
this.InitializeComponent();
}

private void ScrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
{
statusTb.Text = $"Last ScrollViewerViewChangedEventArgs.IsIntermediate = {e.IsIntermediate}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ private bool OnScroll(object sender, RoutedEventArgs routedEventArgs)
var horizontalOffset = GetNativeHorizontalOffset();
var verticalOffset = GetNativeVerticalOffset();
var isIntermediate =
(_lastScrollToRequest.horizontal.HasValue && _lastScrollToRequest.horizontal.Value != horizontalOffset) ||
(_lastScrollToRequest.vertical.HasValue && _lastScrollToRequest.vertical.Value != verticalOffset);
(_lastScrollToRequest.horizontal.HasValue && Math.Abs(_lastScrollToRequest.horizontal.Value - horizontalOffset) >= 1) ||
(_lastScrollToRequest.vertical.HasValue && Math.Abs(_lastScrollToRequest.vertical.Value - verticalOffset) >= 1);
if (!isIntermediate)
{
_lastScrollToRequest = (null, null);
Expand Down

0 comments on commit 62f1f40

Please sign in to comment.