Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Android PanGestureRecognizer jumps back and forth

$
0
0

Hi,

Im trying to do some panning and it works very smooth on iOS but it doesn't on Android. I have the following code:

    ...
    var panGesture = new PanGestureRecognizer();
    panGesture.PanUpdated += PanGesture_PanUpdated;
    handleBar.GestureRecognizers.Add(panGesture);
}

void PanGesture_PanUpdated(object sender, PanUpdatedEventArgs e)
{
        switch (e.StatusType)
        {
            case GestureStatus.Started:
                startX = contentGrid.TranslationX;
                break;

            case GestureStatus.Running:
                contentGrid.TranslationX = startX + e.TotalX;
                Debug.WriteLine($"e.TotalX:{e.TotalX}");
                break;
            }
}

If I swipe from left to right on Android I see this in my logging:

e.TotalX:153,451090494792
e.TotalX:139,719360351563
e.TotalX:157,746846516927
e.TotalX:144,34169514974
e.TotalX:162,310221354167
e.TotalX:149,070007324219
e.TotalX:167,131062825521
e.TotalX:154,131408691406
e.TotalX:172,146565755208
e.TotalX:158,630777994792
e.TotalX:175,341796875
e.TotalX:160,81787109375
e.TotalX:176,309244791667
e.TotalX:161,518229166667

As you can see it jumps back and forth and I see this exact behaviour in the UI on Android. iOS doesn't have this behaviour. Any reason why it jumps like that, and how to fix this?


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>