Skip to content

Commit

Permalink
No inertia if drag is stopped before ending the drag (Leaflet#5690)
Browse files Browse the repository at this point in the history
  • Loading branch information
perliedman authored Aug 9, 2017
1 parent 411ffcc commit b7cbcb3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/map/handler/Map.Drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,21 @@ export var Drag = Handler.extend({
this._positions.push(pos);
this._times.push(time);

if (time - this._times[0] > 50) {
this._positions.shift();
this._times.shift();
}
this._prunePositions(time);
}

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

_prunePositions: function (time) {
while (this._positions.length > 1 && time - this._times[0] > 50) {
this._positions.shift();
this._times.shift();
}
},

_onZoomEnd: function () {
var pxCenter = this._map.getSize().divideBy(2),
pxWorldCenter = this._map.latLngToLayerPoint([0, 0]);
Expand Down Expand Up @@ -192,6 +196,7 @@ export var Drag = Handler.extend({
map.fire('moveend');

} else {
this._prunePositions(+new Date());

var direction = this._lastPos.subtract(this._positions[0]),
duration = (this._lastTime - this._times[0]) / 1000,
Expand Down

0 comments on commit b7cbcb3

Please sign in to comment.