-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a movement threshold for drag panning #1832
Comments
I don't know if we need to make it an option, but I do agree that we should add a tolerance into the click events so that drag/rotate do not start until a user moves more than a few pixels, and clicks do fire even if start/end positions are within the threshold. |
Maybe related. My experience is that in a mobile screen it happens quite often that I unintentionally apparently swipe the map where I meant just to drag it a little with huge leap to 'unknown territory'. I would also like to have a more controlled/ modest dragging somehow. Would it be possible to have a couple of 'drag tweak settings'? |
This is an issue for us as well. On MapboxGL you will need to calculate this by hand by doing something like this:
It would be good to have a distance as a property (as seen here). |
hi @yatiac! thanks for submitting your suggestion. while this is not a high priority for our development team right now, we would happily consider a pull request implementing this option. |
@mollymerp thank you for your response, my team will work on the PR. For now we found another solution that seems simpler:
This can be easily implemented in MapboxGL but we don't have the time right now, if someone else is available, you can take a look at this and implement it in here. |
Re-opening to track the task of integrating this enhancement into GL JS core 😄 |
I think we should leave this as something that is implemented downstream of Mapbox GL JS. Most operating system's have built in tolerance for mouse events, and I don't think Mapbox GL JS should override that by default. |
@jfirebaugh this is a different kind of tolerance than what you are referring to, this issue is not filtered by operating systems. The problem is that when the user clicks on interactive features usually it's not a pixel precise click but a <4px drag, especially when using a mouse. Leaflet had this implemented in core and I agree that this would be nice to have in a polished/tested form in Mapbox GL JS core. |
I'm using mapbox-gl for a very click-heavy application and this issue was starting to bother me. Submitted a pull request that attempts to fix this. Let me know you think. |
@msbarry this is so nice, thanks for making it into a PR! |
As a user, very easy to trigger drag event when you really meant for a click event. Can listen to dragstart+end and fire click if drag was only a pixel or two, but wondering if there is an option to set drag threshold directly.. if not, should there be?
The text was updated successfully, but these errors were encountered: