Android pan TotalX/TotalY bad when the gesture recognizer view is affected by layout change
#3469 aperta il 2 ago 2018
Metriche repository
- Star
- (5644 stelle)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
Description
On Android, if the view that holds a pan gesture recognizer is affected by a layout change while the pan is running, then the TotalX and TotalY values are incorrect. iOS and UWP do not have this problem. The values are less than they should be, and there is "jitter" in the values as they step up and partially back during a linear pan operation.
Others have noticed this problem:
- https://forums.xamarin.com/discussion/118226/android-pangesturerecognizer-jumps-back-and-forth
- https://forums.xamarin.com/discussion/87287/pangesturerecognizer-behaves-not-as-expected
- https://stackoverflow.com/questions/39458078/xamarin-pan-gesture-recognizer-not-giving-accurate-coordinates
- ...
I have attached a very simple iOS/Android/UWP project that illustrates the problem. The view with the pan gesture is in the bottom row of a grid, and the grid rows are resized as the pan occurs. See the screenshot below.
Steps to Reproduce
- Add a PanGestureRecognizer to a control on a page
- Handle the PanUpdated event, and update the location of the control (or its container) relative to the PanUpdated TotalX/TotalY values
Expected Behavior
On iOS and UWP, the TotalX/TotalY values in the PanUpdated event args will be correct and the affected control moves as expected
Actual Behavior
On Android, the control location lags the mouse position, and the location has "jitter"...jumps around as it moves
Basic Information
- Version with issue: 2.x, 3.x
- Last known good version: Unknown if any
- Platform Target Frameworks:
- Android: 8.1 (but the problem existed in previous versions as well)
Screenshots
Here it is in action (the jitter is not apparent in this compressed gif format):
