Improve polyline/polygon drawing by accepting some motion on click #249

Merged
merged 1 commit into from Jan 13, 2014

Conversation

Projects
None yet
3 participants
Contributor

atombender commented Dec 19, 2013

This change improves polyline/polygon drawing by accepting clicks that involve a little bit of mouse motion.

The problem is that Leaflet.draw will miss most of the points if one quickly (or even not terribly quickly) tries to draw a shape such as a polygon. This is because clicking using a physical mounse typically introduces a little bit of motion to the on-screen mouse cursor. Such clicks will be perceived as a map move event, not a draw click.

The solution is to hook mousedown rather than click, and track the distance of the motion when mouseup is received.

Owner

jacobtoye commented Dec 19, 2013

Oh this looks pretty cool! Could you pull in the latest changes to get this merge lined up :)

@atombender atombender Improve polyline/polygon drawing by accepting clicks that involve a l…
…ittle bit of mouse motion.

The problem is that Leaflet.draw will miss most of the points if one quickly (or even not terribly quickly) tries to draw a shape such as a polygon. This is because clicking using a physical mounse typically introduces a little bit of motion to the on-screen mouse cursor. Such clicks will be perceived as a map move event, not a draw click.

The solution is to hook `mousedown` rather than `click`, and track the distance of the motion when `mouseup` is received.
8fa1432
Contributor

atombender commented Dec 19, 2013

Done — sorry, forgot to fetch before I did the PR.

Contributor

Zverik commented Dec 28, 2013

There is a chance this PR will allow drawing on mobile devices (namely on Nokia Browser).

@jacobtoye jacobtoye added a commit that referenced this pull request Jan 13, 2014

@jacobtoye jacobtoye Merge pull request #249 from atombender/master
Improve polyline/polygon drawing by accepting some motion on click
fd30a0a

@jacobtoye jacobtoye merged commit fd30a0a into Leaflet:master Jan 13, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment