Skip to content

Commit

Permalink
prevent gesture recognition when gesture is captured (#13323)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmauss authored and maxkatz6 committed Dec 5, 2023
1 parent 57f7622 commit 6794148
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public abstract class GestureRecognizer : StyledElement
{
private PointerEventArgs? _currentPointerEventArgs;
protected internal IInputElement? Target { get; internal set; }

protected abstract void PointerPressed(PointerPressedEventArgs e);
Expand All @@ -11,17 +12,23 @@ public abstract class GestureRecognizer : StyledElement

internal void PointerPressedInternal(PointerPressedEventArgs e)
{
_currentPointerEventArgs = e;
PointerPressed(e);
_currentPointerEventArgs = null;
}

internal void PointerReleasedInternal(PointerReleasedEventArgs e)
{
_currentPointerEventArgs = e;
PointerReleased(e);
_currentPointerEventArgs = null;
}

internal void PointerMovedInternal(PointerEventArgs e)
{
_currentPointerEventArgs = e;
PointerMoved(e);
_currentPointerEventArgs = null;
}

internal void PointerCaptureLostInternal(IPointer pointer)
Expand All @@ -32,6 +39,8 @@ internal void PointerCaptureLostInternal(IPointer pointer)
protected void Capture(IPointer pointer)
{
(pointer as Pointer)?.CaptureGestureRecognizer(this);

_currentPointerEventArgs?.PreventGestureRecognition();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ protected override void PointerMoved(PointerEventArgs e)
{
var currentPosition = e.GetPosition(visual);
Capture(e.Pointer);
e.PreventGestureRecognition();

Vector delta = default;
switch (PullDirection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ protected override void PointerMoved(PointerEventArgs e)
_trackedRootPoint.Y - (_trackedRootPoint.Y >= rootPoint.Y ? ScrollStartDistance : -ScrollStartDistance));

Capture(e.Pointer);

e.PreventGestureRecognition();
}
}

Expand Down

0 comments on commit 6794148

Please sign in to comment.