diff --git a/src/map/Map.js b/src/map/Map.js index 5367ba33..4817dc1e 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -211,15 +211,17 @@ L.Map = L.Class.extend({ var offset = oldSize._subtract(this.getSize())._divideBy(2)._round(); - if (animate === true) { - this.panBy(offset); - } else { - this._rawPanBy(offset); + if ((offset.x !== 0) || (offset.y !== 0)) { + if (animate === true) { + this.panBy(offset); + } else { + this._rawPanBy(offset); - this.fire('move'); + this.fire('move'); - clearTimeout(this._sizeTimer); - this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200); + clearTimeout(this._sizeTimer); + this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200); + } } return this; }, diff --git a/src/map/anim/Map.PanAnimation.js b/src/map/anim/Map.PanAnimation.js index c1bd3077..0b140eeb 100644 --- a/src/map/anim/Map.PanAnimation.js +++ b/src/map/anim/Map.PanAnimation.js @@ -32,7 +32,7 @@ L.Map.include({ return this; }, - panBy: function (offset, duration, easeLinearity) { + panBy: function (offset, duration, easeLinearity, moving) { offset = L.point(offset); if (!(offset.x || offset.y)) { @@ -48,7 +48,9 @@ L.Map.include({ }, this); } - this.fire('movestart'); + if (moving !== true) { + this.fire('movestart'); + } L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim'); diff --git a/src/map/handler/Map.Drag.js b/src/map/handler/Map.Drag.js index 529ebf5d..323ee927 100644 --- a/src/map/handler/Map.Drag.js +++ b/src/map/handler/Map.Drag.js @@ -111,6 +111,8 @@ L.Map.Drag = L.Handler.extend({ noInertia = !options.inertia || delay > options.inertiaThreshold || !this._positions[0]; + map.fire('dragend'); + if (noInertia) { map.fire('moveend'); @@ -130,12 +132,10 @@ L.Map.Drag = L.Handler.extend({ offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round(); L.Util.requestAnimFrame(function () { - map.panBy(offset, decelerationDuration, ease); + map.panBy(offset, decelerationDuration, ease, true); }); } - map.fire('dragend'); - if (options.maxBounds) { // TODO predrag validation instead of animation L.Util.requestAnimFrame(this._panInsideMaxBounds, map, true, map._container);