Skip to content

Commit

Permalink
fix: Workaround FlipView issue on Wasm when jumping >= 2 indices
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Nov 21, 2023
1 parent e7ae842 commit e10c247
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Uno.UI.FluentTheme.v2/themeresources_v2.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19837,11 +19837,11 @@
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
<contract7Present:Setter Property="CornerRadius" Value="{StaticResource ControlCornerRadius}" />
<Setter Property="CornerRadius" Value="{StaticResource ControlCornerRadius}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="RootGrid" Background="{TemplateBinding Background}" contract7Present:CornerRadius="{TemplateBinding CornerRadius}" contract7NotPresent:CornerRadius="{StaticResource ControlCornerRadius}">
<Grid x:Name="RootGrid" Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding CornerRadius}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
Expand Down Expand Up @@ -19890,7 +19890,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ContentPresenter x:Name="ContentPresenter" Background="{TemplateBinding Background}" contract7Present:BackgroundSizing="{TemplateBinding BackgroundSizing}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" contract7Present:CornerRadius="{TemplateBinding CornerRadius}" contract7NotPresent:CornerRadius="{ThemeResource ControlCornerRadius}" Padding="{TemplateBinding Padding}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" AutomationProperties.AccessibilityView="Raw">
<ContentPresenter x:Name="ContentPresenter" Background="{TemplateBinding Background}" BackgroundSizing="{TemplateBinding BackgroundSizing}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" CornerRadius="{TemplateBinding CornerRadius}" Padding="{TemplateBinding Padding}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" AutomationProperties.AccessibilityView="Raw">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
Expand Down
9 changes: 7 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/FlipView/FlipView.managed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,10 @@ void UnhookTemplate()
if (m_tpScrollViewer != null)
{
m_tpScrollViewer.SizeChanged -= OnScrollingHostPartSizeChanged;
m_tpScrollViewer.ViewChanged -= OnScrollViewerViewChanged;

#if !__WASM__
m_tpScrollViewer.ViewChanged -= OnScrollViewerViewChanged;
#endif
}

m_tpButtonsFadeOutTimer?.Stop();
Expand Down Expand Up @@ -482,7 +485,9 @@ void InitializeScrollViewer()
// return OnScrollViewerViewChanged(pSender, pArgs);
//}));

#if !__WASM__ // Workaround for https://github.com/unoplatform/uno/issues/14488
m_tpScrollViewer.ViewChanged += OnScrollViewerViewChanged;
#endif
}
}
}
Expand Down Expand Up @@ -1511,7 +1516,7 @@ internal override void OnSelectedIndexChanged(int oldSelectedIndex, int newSelec
// with SetFixOffsetTimer.
if (m_animateNewIndex)
{
bool succeeded = (bool)(m_tpScrollViewer?.CancelDirectManipulations());
//bool succeeded = (bool)(m_tpScrollViewer?.CancelDirectManipulations());
RestoreSnapPointsTypes();
m_animateNewIndex = false;
SetFixOffsetTimer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ private IReadOnlyList<float> CopyMotionSnapPoints(
{
global::System.Diagnostics.Debug.Assert(staticZoomFactor == 1f || staticZoomFactor == zoomFactor);

if (snapPoints is null)
{
return null;
}

var result = new List<float>(snapPoints.Count);

if (snapPoints.Count > 0)
Expand Down

0 comments on commit e10c247

Please sign in to comment.