[Pkg-javascript-commits] [leaflet] 41/301: Fix for zoomBox fires map click Event (Issue #1884)
Jonas Smedegaard
js at moszumanska.debian.org
Mon Jan 27 22:22:40 UTC 2014
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet.
commit c1e64c2479db779639af2571e6f7acfe7a95fb77
Author: fastrde <strachanski at googlemail.com>
Date: Thu Aug 8 15:15:39 2013 +0200
Fix for zoomBox fires map click Event (Issue #1884)
---
src/map/Map.js | 4 +++-
src/map/handler/Map.BoxZoom.js | 11 +++++++++--
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/map/Map.js b/src/map/Map.js
index 5bfd392..744cf41 100644
--- a/src/map/Map.js
+++ b/src/map/Map.js
@@ -676,7 +676,9 @@ L.Map = L.Class.extend({
},
_onMouseClick: function (e) {
- if (!this._loaded || (!e._simulated && this.dragging && this.dragging.moved()) ||
+ if (!this._loaded ||
+ (!e._simulated && this.dragging && this.dragging.moved()) ||
+ (!e._simulated && this.boxZoom && this.boxZoom.zoomed()) ||
L.DomEvent._skipped(e)) { return; }
this.fire('preclick');
diff --git a/src/map/handler/Map.BoxZoom.js b/src/map/handler/Map.BoxZoom.js
index a91095f..db61baf 100644
--- a/src/map/handler/Map.BoxZoom.js
+++ b/src/map/handler/Map.BoxZoom.js
@@ -12,6 +12,7 @@ L.Map.BoxZoom = L.Handler.extend({
this._map = map;
this._container = map._container;
this._pane = map._panes.overlayPane;
+ this._zoomed = false;
},
addHooks: function () {
@@ -20,9 +21,13 @@ L.Map.BoxZoom = L.Handler.extend({
removeHooks: function () {
L.DomEvent.off(this._container, 'mousedown', this._onMouseDown);
+ this._zoomed = false;
+ },
+ zoomed: function () {
+ return this._zoomed;
},
-
_onMouseDown: function (e) {
+ this._zoomed = false;
if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; }
L.DomUtil.disableTextSelection();
@@ -56,7 +61,9 @@ L.Map.BoxZoom = L.Handler.extend({
Math.min(layerPoint.y, startPoint.y));
L.DomUtil.setPosition(box, newPos);
-
+ if (!this._zoomed) {
+ this._zoomed = 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';
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet.git
More information about the Pkg-javascript-commits
mailing list