Skip to content
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

draggable marker + mousedown event problem #2557

Closed
AndriiHeonia opened this issue Mar 19, 2014 · 4 comments
Closed

draggable marker + mousedown event problem #2557

AndriiHeonia opened this issue Mar 19, 2014 · 4 comments
Milestone

Comments

@AndriiHeonia
Copy link
Contributor

Code:

map.on('mousedown', function(e) {
    var marker = L.marker(e.latlng, {draggable: true});
    marker.addTo(map);
    marker.on('click', function(e){console.log(e)});
});

How to reproduce bug:

  1. mousedown on map, drag, mouseup;
  2. click on the created marker.
    Expected result: event printed to console.
    Actual result: event is not handled.

It looks as my click event handler is lost during the dragging.

Browser: Chrome 33.0.1750.152
OS: Ubuntu
Leaflet version: current master (0.8)

@mourner mourner added this to the unconfirmed milestone Mar 19, 2014
@jfirebaugh jfirebaugh modified the milestones: 1.0-beta, unconfirmed Mar 19, 2014
@jfirebaugh
Copy link
Member

I can replicate this. Bisected to 7ca19b5.

@jfirebaugh
Copy link
Member

The general bug here is that draggable markers don't receive click events after dragging the map. The events get discarded here. Normally, this wouldn't happen, because _moved gets reset on the mousedown immediately preceding the click. But for draggable markers, there are two L.Draggable's competing for the mousedown event: L.Marker.Drag's Draggable and L.Map.Drag's Draggable. The first one wins, and stops propagation. The map's _moved flag, which is true from the preceding drag, never gets reset.

Prior to 7ca19b5 this worked as desired because L.Marker fired the click event itself rather than going through this._map._fireMouseEvent.

@AndriiHeonia
Copy link
Contributor Author

I think it should be fixed by my commit in #2619 issue. @Gaidamak, can you test it?

@Gaidamak
Copy link

Gaidamak commented Aug 5, 2014

This problem fixed by #2619 @AndreyGeonya

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants