No inertia if drag is stopped before ending the drag (#5690)

Fixes #5652.
This commit is contained in:
Per Liedman 2017-08-09 14:16:06 +02:00 committed by GitHub
parent 411ffcced9
commit b7cbcb39b8

View File

@ -129,10 +129,7 @@ export var Drag = Handler.extend({
this._positions.push(pos); this._positions.push(pos);
this._times.push(time); this._times.push(time);
if (time - this._times[0] > 50) { this._prunePositions(time);
this._positions.shift();
this._times.shift();
}
} }
this._map this._map
@ -140,6 +137,13 @@ export var Drag = Handler.extend({
.fire('drag', 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 () { _onZoomEnd: function () {
var pxCenter = this._map.getSize().divideBy(2), var pxCenter = this._map.getSize().divideBy(2),
pxWorldCenter = this._map.latLngToLayerPoint([0, 0]); pxWorldCenter = this._map.latLngToLayerPoint([0, 0]);
@ -192,6 +196,7 @@ export var Drag = Handler.extend({
map.fire('moveend'); map.fire('moveend');
} else { } else {
this._prunePositions(+new Date());
var direction = this._lastPos.subtract(this._positions[0]), var direction = this._lastPos.subtract(this._positions[0]),
duration = (this._lastTime - this._times[0]) / 1000, duration = (this._lastTime - this._times[0]) / 1000,