[Pkg-javascript-commits] [leaflet] 184/301: add distance to dragend event data, close #2158, ref #872

Jonas Smedegaard js at moszumanska.debian.org
Mon Jan 27 22:22:50 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 ddbb01c3dae78cc4c5900a40633702a018f29dce
Author: Vladimir Agafonkin <agafonkin at gmail.com>
Date:   Wed Nov 6 21:17:35 2013 +0200

    add distance to dragend event data, close #2158, ref #872
---
 CHANGELOG.md                    | 1 +
 src/dom/Draggable.js            | 4 +++-
 src/layer/marker/Marker.Drag.js | 4 ++--
 src/map/handler/Map.Drag.js     | 4 ++--
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index b418875..642b8b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,7 @@ An in-progress version being developed on the `master` branch.
 * Made `Map` `setView` `zoom` argument optional. [#2056](https://github.com/Leaflet/Leaflet/issues/2056)
 * Added `maxZoom` option to `Map` `fitBounds`. [#2101](https://github.com/Leaflet/Leaflet/issues/2101)
 * Added `Map` `bounceAtZoomLimits` option that makes the map bounce when you pinch-zoom past limits (it worked like this before, but now you can disable this) (by [@trevorpowell](https://github.com/trevorpowell)). [#1864](https://github.com/Leaflet/Leaflet/issues/1864) [#2072](https://github.com/Leaflet/Leaflet/pull/2072)
+* Added `distance` property to `Map` and `Marker` `dragend` events. [#2158](https://github.com/Leaflet/Leaflet/issues/2158) [#872](https://github.com/Leaflet/Leaflet/issues/872)
 * Added optional support for center-oriented scroll and double-click zoom (by [@jfirebaugh](https://github.com/jfirebaugh)). [#1939](https://github.com/Leaflet/Leaflet/issues/1939)
 * Added `timestamp` to `Map` `locationfound` event. [#584](https://github.com/Leaflet/Leaflet/pull/584)
 * Added CSS classes to draggable markers for easier customization (by [@snkashis](https://github.com/snkashis)). [#1902](https://github.com/Leaflet/Leaflet/issues/1902) [#1916](https://github.com/Leaflet/Leaflet/issues/1916)
diff --git a/src/dom/Draggable.js b/src/dom/Draggable.js
index d59fec0..9c20fe2 100644
--- a/src/dom/Draggable.js
+++ b/src/dom/Draggable.js
@@ -127,7 +127,9 @@ L.Draggable = L.Class.extend({
 			// ensure drag is not fired after dragend
 			L.Util.cancelAnimFrame(this._animRequest);
 
-			this.fire('dragend');
+			this.fire('dragend', {
+				distance: this._newPos.distanceTo(this._startPos)
+			});
 		}
 
 		this._moving = false;
diff --git a/src/layer/marker/Marker.Drag.js b/src/layer/marker/Marker.Drag.js
index b8ca80f..f71fe8f 100644
--- a/src/layer/marker/Marker.Drag.js
+++ b/src/layer/marker/Marker.Drag.js
@@ -61,10 +61,10 @@ L.Handler.MarkerDrag = L.Handler.extend({
 		    .fire('drag');
 	},
 
-	_onDragEnd: function () {
+	_onDragEnd: function (e) {
 		this._marker
 		    .fire('moveend')
-		    .fire('dragend');
+		    .fire('dragend', e);
 		L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-dragging');
 	}
 });
diff --git a/src/map/handler/Map.Drag.js b/src/map/handler/Map.Drag.js
index 1024f15..fc2b79d 100644
--- a/src/map/handler/Map.Drag.js
+++ b/src/map/handler/Map.Drag.js
@@ -104,14 +104,14 @@ L.Map.Drag = L.Handler.extend({
 		this._draggable._newPos.x = newX;
 	},
 
-	_onDragEnd: function () {
+	_onDragEnd: function (e) {
 		var map = this._map,
 		    options = map.options,
 		    delay = +new Date() - this._lastTime,
 
 		    noInertia = !options.inertia || delay > options.inertiaThreshold || !this._positions[0];
 
-		map.fire('dragend');
+		map.fire('dragend', e);
 
 		if (noInertia) {
 			map.fire('moveend');

-- 
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