Skip to content

Commit

Permalink
Merge pull request #3264 from yohanboniface/drag-original-event
Browse files Browse the repository at this point in the history
Forward original event on drag
  • Loading branch information
mourner committed Mar 2, 2015
2 parents 08cf1ef + 1e4b82b commit f27ead2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/dom/Draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ L.Draggable = L.Evented.extend({
this._moving = true;

L.Util.cancelAnimFrame(this._animRequest);
this._lastEvent = e;
this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true, this._dragStartTarget);
},

_updatePosition: function () {
this.fire('predrag');
var e = {originalEvent: this._lastEvent};
this.fire('predrag', e);
L.DomUtil.setPosition(this._element, this._newPos);
this.fire('drag');
this.fire('drag', e);
},

_onUp: function () {
Expand Down
7 changes: 4 additions & 3 deletions src/layer/marker/Marker.Drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
.fire('drag', e);
},

_onDragEnd: function (e) {
Expand Down
6 changes: 3 additions & 3 deletions src/map/handler/Map.Drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ L.Map.Drag = L.Handler.extend({
}
},

_onDrag: function () {
_onDrag: function (e) {
if (this._map.options.inertia) {
var time = this._lastTime = +new Date(),
pos = this._lastPos = this._draggable._absPos || this._draggable._newPos;
Expand All @@ -78,8 +78,8 @@ L.Map.Drag = L.Handler.extend({
}

this._map
.fire('move')
.fire('drag');
.fire('move', e)
.fire('drag', e);
},

_onViewReset: function () {
Expand Down

0 comments on commit f27ead2

Please sign in to comment.