Skip to content

Commit

Permalink
fix(scrollviewer): raise PointerEnter/Exit when scrolling causes the …
Browse files Browse the repository at this point in the history
…pointer to be over a new item

(cherry picked from commit 2fd9da2)
  • Loading branch information
ramezgerges authored and mergify[bot] committed Aug 11, 2023
1 parent 5bf4c2c commit ae436b6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Uno.UI/UI/Xaml/Internal/InputManager.Pointers.Managed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private void UpdateLastInputType(PointerEventArgs e)

private void OnPointerWheelChanged(Windows.UI.Core.PointerEventArgs args)
{
var (originalSource, _) = HitTest(args);
var (originalSource, staleBranch) = HitTest(args, _isOver);

// Even if impossible for the Release, we are fallbacking on the RootElement for safety
// This is how UWP behaves: when out of the bounds of the Window, the root element is use.
Expand All @@ -129,7 +129,19 @@ private void OnPointerWheelChanged(Windows.UI.Core.PointerEventArgs args)

var routedArgs = new PointerRoutedEventArgs(args, originalSource);

// Second raise the event, either on the OriginalSource or on the capture owners if any
// First raise the PointerExited events on the stale branch
if (staleBranch.HasValue)
{
if (Raise(Leave, staleBranch.Value, routedArgs) is { VisualTreeAltered: true })
{
// The visual tree has been modified in a way that requires performing a new hit test.
originalSource = HitTest(args, caller: "OnPointerMoved_post_leave").element ?? _inputManager._contentRoot.VisualTree.RootElement;
}
// Second raise the PointerEntered events on the OriginalSource
RaiseUsingCaptures(Enter, originalSource, routedArgs);
}

// Third raise the event, either on the OriginalSource or on the capture owners if any
RaiseUsingCaptures(Wheel, originalSource, routedArgs);
}

Expand Down

0 comments on commit ae436b6

Please sign in to comment.