some tweaks to #1951

This commit is contained in:
Vladimir Agafonkin 2013-08-09 14:00:44 +03:00
parent 30f33766dd
commit 4609d482f2
2 changed files with 15 additions and 12 deletions

View File

@ -676,10 +676,10 @@ L.Map = L.Class.extend({
},
_onMouseClick: function (e) {
if (!this._loaded ||
(!e._simulated && this.dragging && this.dragging.moved()) ||
(!e._simulated && this.boxZoom && this.boxZoom.zoomed()) ||
L.DomEvent._skipped(e)) { return; }
if (!this._loaded || (!e._simulated &&
((this.dragging && this.dragging.moved()) ||
(this.boxZoom && this.boxZoom.moved()))) ||
L.DomEvent._skipped(e)) { return; }
this.fire('preclick');
this._fireMouseEvent(e);

View File

@ -12,7 +12,7 @@ L.Map.BoxZoom = L.Handler.extend({
this._map = map;
this._container = map._container;
this._pane = map._panes.overlayPane;
this._zoomed = false;
this._moved = false;
},
addHooks: function () {
@ -21,13 +21,16 @@ L.Map.BoxZoom = L.Handler.extend({
removeHooks: function () {
L.DomEvent.off(this._container, 'mousedown', this._onMouseDown);
this._zoomed = false;
this._moved = false;
},
zoomed: function () {
return this._zoomed;
moved: function () {
return this._moved;
},
_onMouseDown: function (e) {
this._zoomed = false;
this._moved = false;
if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; }
L.DomUtil.disableTextSelection();
@ -61,9 +64,9 @@ L.Map.BoxZoom = L.Handler.extend({
Math.min(layerPoint.y, startPoint.y));
L.DomUtil.setPosition(box, newPos);
if (!this._zoomed) {
this._zoomed = true;
}
this._moved = true;
// TODO refactor: remove hardcoded 4 pixels
box.style.width = (Math.max(0, Math.abs(offset.x) - 4)) + 'px';
box.style.height = (Math.max(0, Math.abs(offset.y) - 4)) + 'px';