Fix boxZoom._moved remaining in bad state after use (cf #3026)

This commit is contained in:
Yohan Boniface 2015-07-17 11:09:15 +02:00
parent 21934dc2b3
commit 8870c2abf8
2 changed files with 9 additions and 2 deletions

View File

@ -43,7 +43,7 @@
function logEvent(e) { console.log(e.type); }
// map.on('click', logEvent);
map.on('click', logEvent);
// map.on('movestart', logEvent);
// map.on('move', logEvent);

View File

@ -26,10 +26,14 @@ L.Map.BoxZoom = L.Handler.extend({
return this._moved;
},
_resetState: function () {
this._moved = false;
},
_onMouseDown: function (e) {
if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; }
this._moved = false;
this._resetState();
L.DomUtil.disableTextSelection();
L.DomUtil.disableImageDrag();
@ -88,6 +92,9 @@ L.Map.BoxZoom = L.Handler.extend({
this._finish();
if (!this._moved) { return; }
// Postpone to next JS tick so internal click event handling
// still see it as "moved".
setTimeout(L.bind(this._resetState, this), 0);
var bounds = new L.LatLngBounds(
this._map.containerPointToLatLng(this._startPoint),