AvaloniaUI / Avalonia.Labs

Experimental Controls for Avalonia
MIT License
194 stars 25 forks source link

PanGestureRecognizer is not raising Completed event #69

Closed mikegoatly closed 3 months ago

mikegoatly commented 3 months ago

I noticed that the Swipe control isn't working at the moment:

https://github.com/AvaloniaUI/Avalonia.Labs/assets/4577868/a128bbf0-a688-448c-bebb-391877fdbe64

I did a bit of digging and found that PanGestureRecognizer isn't currently raising its PanUpdatedEvent event with the Completed status. Comparing the logic in the current ScrollGestureRecognizer, the most significant difference I can see is that the PanGestureRecognizer isn't keeping track of which pointer is responsible for the gesture, and it's capturing the pointer both with e.Pointer.Capture(_inputElement); and `Capture(e.Pointer).

Updating the recognizer to track the pointer, and only Capture(e.Pointer) means the Swipe control starts behaving itself:

https://github.com/AvaloniaUI/Avalonia.Labs/assets/4577868/26feff2c-334a-4cfe-98f4-19ead7b80d0b

I've a PR incoming with the changes I've made for review.