-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Forward original event on drag #3264
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ L.Handler.MarkerDrag = L.Handler.extend({ | |
.fire('dragstart'); | ||
}, | ||
|
||
_onDrag: function () { | ||
_onDrag: function (e) { | ||
var marker = this._marker, | ||
shadow = marker._shadow, | ||
iconPos = L.DomUtil.getPosition(marker._icon), | ||
|
@@ -58,10 +58,11 @@ L.Handler.MarkerDrag = L.Handler.extend({ | |
} | ||
|
||
marker._latlng = latlng; | ||
e.latlng = latlng; | ||
|
||
marker | ||
.fire('move', {latlng: latlng}) | ||
.fire('drag'); | ||
.fire('move', e) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like modified DOM event being passed as event data... In a similar situation in other place of Leaflet code, original event is passed as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally done that, but then changed my mind, finding this version lighter, but I'll do that then :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, as we are doing two forwards, I'm not sure at which step we should introduce the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably at the start. |
||
.fire('drag', e); | ||
}, | ||
|
||
_onDragEnd: function (e) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use
L.bind(animationCallback, null, e)
instead. Orthis._lastEvent
to avoid closure entirely.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
Which one do you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest (
this._lastEvent
) may be more readable, given that we are already passing a buntch of arguments torequestAnimFrame
.