From b8b6e3e8528f0f1270f98dbbac9723b5c0079eab Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 5 Dec 2013 14:43:41 +0200 Subject: [PATCH] clean up Marker.Drag.js --- src/layer/marker/Marker.Drag.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/layer/marker/Marker.Drag.js b/src/layer/marker/Marker.Drag.js index 812439f8..e03fa716 100644 --- a/src/layer/marker/Marker.Drag.js +++ b/src/layer/marker/Marker.Drag.js @@ -9,6 +9,7 @@ L.Handler.MarkerDrag = L.Handler.extend({ addHooks: function () { var icon = this._marker._icon; + if (!this._draggable) { this._draggable = new L.Draggable(icon, icon); } @@ -16,18 +17,19 @@ L.Handler.MarkerDrag = L.Handler.extend({ this._draggable .on('dragstart', this._onDragStart, this) .on('drag', this._onDrag, this) - .on('dragend', this._onDragEnd, this); - this._draggable.enable(); - L.DomUtil.addClass(this._marker._icon, 'leaflet-marker-draggable'); + .on('dragend', this._onDragEnd, this) + .enable(); + + L.DomUtil.addClass(icon, 'leaflet-marker-draggable'); }, removeHooks: function () { this._draggable .off('dragstart', this._onDragStart, this) .off('drag', this._onDrag, this) - .off('dragend', this._onDragEnd, this); + .off('dragend', this._onDragEnd, this) + .disable(); - this._draggable.disable(); L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable'); },