xamarin/Xamarin.Forms

Swiped Event of SwipeGestureRecognizer does not contain actual direction

Open

#4,473 opened on Nov 19, 2018

 (9 comments) (0 reactions) (0 assignees)C# (1,926 forks)batch import
a/gestures 🖖e/3 :clock3:help wantedinactiveproposal-opent/bug :bug:t/enhancement ➕up-for-grabs

Repository metrics

Stars
 (5,644 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Description

The Swiped event of SwipeGestureRecognizer does not contain actual direction

Steps to Reproduce

Create a new page and in Xaml:

<!-- Swipe Gesture -->
<Label Text="Swipe Gesture" class="featureHeader" Margin="0,20,0,10"/>
<BoxView BackgroundColor="Black" Margin="0,0,0,10" HeightRequest="1"/>
<Label Text="Swipe right-to-left or left-to-right on the green box below." Margin="0,10"/>
<BoxView BackgroundColor="Lime" WidthRequest="300" HeightRequest="300">
    <BoxView.GestureRecognizers>
        <SwipeGestureRecognizer
            Direction="Right, Left"
            Swiped="SwipeGestureRecognizer_Swiped" />
    </BoxView.GestureRecognizers>
</BoxView>

In code:

private async void SwipeGestureRecognizer_Swiped(object sender, SwipedEventArgs e)
{
    await DisplayAlert("Swiper No Swiping!", $"Yay! You swiped to the {e.Direction}!", "Close");
}

Run the app and swipe either way,

code sample taken from TheLittleThingsPlayground

Actual Behavior

image

Expected Behavior

The message should tell the actual direction of the swipe, either Right or Left, I didn't swipe in both directions at the same time

Basic Information

Testing on:

  • Xamarin.Forms: 3.4
  • IDE: 15.9
    • iOS: 12.1

Contributor guide