Skip to content

Commit

Permalink
fix(pointers): Make sure to abort drag manipulation as soon as possib…
Browse files Browse the repository at this point in the history
…le if not touch pointer
  • Loading branch information
dr1rrb committed Sep 27, 2021
1 parent a5caead commit 1045c76
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public ScrollContentPresenter()
// Touch scroll support
ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY; // Updated in PrepareTouchScroll!
ManipulationStarting += PrepareTouchScroll;
ManipulationStarted += BeginTouchScroll;
ManipulationDelta += UpdateTouchScroll;
ManipulationCompleted += CompleteTouchScroll;

Expand Down Expand Up @@ -238,6 +237,12 @@ private void ScrollContentPresenter_PointerWheelChanged(object sender, Input.Poi

private void PrepareTouchScroll(object sender, ManipulationStartingRoutedEventArgs e)
{
if (e.Pointer.Type != PointerDeviceType.Touch)
{
e.Mode = ManipulationModes.None;
return;
}

if (!CanVerticallyScroll || ExtentHeight <= 0)
{
e.Mode &= ~ManipulationModes.TranslateY;
Expand All @@ -249,15 +254,6 @@ private void PrepareTouchScroll(object sender, ManipulationStartingRoutedEventAr
}
}

private void BeginTouchScroll(object sender, ManipulationStartedRoutedEventArgs e)
{
if (e.PointerDeviceType != PointerDeviceType.Touch)
{
e.Complete();
return;
}
}

private void UpdateTouchScroll(object sender, ManipulationDeltaRoutedEventArgs e)
=> Set(
horizontalOffset: HorizontalOffset - e.Delta.Translation.X,
Expand Down

0 comments on commit 1045c76

Please sign in to comment.