Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scrollviewer): fix scrollArgs.IsIntermediate on WASm (backport #18883) #18891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading