mapbox / mapbox-plugins-android

Mapbox Android Plugins are a collection of libraries that extend our other SDKs, helping you design powerful mapping features while the plugins handle most of the heavy lifting.
https://www.mapbox.com/android-docs/plugins/overview/
BSD 2-Clause "Simplified" License
241 stars 120 forks source link

Implement cancel draggable during onAnnotationDrag #1129

Open Ph0tonic opened 4 years ago

Ph0tonic commented 4 years ago

While using this plugin, I needed to cancel a drag event when my point was further apart from another location. The way I solved this was by deleting the point and repainting it so that cancel the drag event. The problem is that it's not efficient at all.

Here is a proposal to allow a drag event to be canceled directly in the dragEventListener. I would be pleased to have your feedback @langsmith and @LukasPaczos.

Thanks in advance

LukasPaczos commented 4 years ago

Thanks @Ph0tonic, the idea and the implementation look good to me. Would you be able to add a unit test?

@langsmith could you help with merging this when ready?

Ph0tonic commented 4 years ago

You're welcome. Hum yes I will try to add some test but I not sure any more of my implementation. In the present case when a drag is cancel then the annotation stay still and if we continue our movement then the map moves. I think that this should not happen and could be very strange to the user has he was moving an annotation and suddenly he is moving the map.

What do you think about cancelling the drag but still consuming the event such as to prevent the map to take back the event until the user end is drag ?