diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e1d9f09..a32aec11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ An in-progress version being developed on the master branch. * Fixed a bug with pan animation where it jumped to its end position if you tried to drag the map. * Fixed a bug with shift-clicking on a zoom button leading to unexpected result. + * Fixed a glitch with zooming in while panning animation is running. + * Fixed a glitch with dragging the map while zoom animation is running. * Fixed a bug where "Not implemented" error sometimes appeared in IE6-8 (by [@bryguy](https://github.com/bryguy) and [@lookfirst](https://github.com/lookfirst)). [#892](https://github.com/CloudMade/Leaflet/issues/892) [#893](https://github.com/CloudMade/Leaflet/pull/893) ## 0.4.4 (August 7, 2012) diff --git a/src/dom/Draggable.js b/src/dom/Draggable.js index e3385f71..68681ef7 100644 --- a/src/dom/Draggable.js +++ b/src/dom/Draggable.js @@ -35,9 +35,12 @@ L.Draggable = L.Class.extend({ }, _onDown: function (e) { - if ((!L.Browser.touch && e.shiftKey) || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { - return; - } + if ((!L.Browser.touch && e.shiftKey) || + ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; } + + L.DomEvent.preventDefault(e); + + if (L.Draggable._disabled) { return; } this._simulateClick = true; @@ -49,8 +52,6 @@ L.Draggable = L.Class.extend({ var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e), el = first.target; - L.DomEvent.preventDefault(e); - if (L.Browser.touch && el.tagName.toLowerCase() === 'a') { L.DomUtil.addClass(el, 'leaflet-active'); } diff --git a/src/map/anim/Map.PanAnimation.js b/src/map/anim/Map.PanAnimation.js index 0826f5ff..4fa10e0c 100644 --- a/src/map/anim/Map.PanAnimation.js +++ b/src/map/anim/Map.PanAnimation.js @@ -7,6 +7,11 @@ L.Map.include({ var zoomChanged = (this._zoom !== zoom); if (this._loaded && !forceReset && this._layers) { + + if (this._panAnim) { + this._panAnim.stop(); + } + var done = (zoomChanged ? this._zoomToIfClose && this._zoomToIfClose(center, zoom) : this._panByIfClose(center)); diff --git a/src/map/anim/Map.ZoomAnimation.js b/src/map/anim/Map.ZoomAnimation.js index 62bb1f02..9fe59143 100644 --- a/src/map/anim/Map.ZoomAnimation.js +++ b/src/map/anim/Map.ZoomAnimation.js @@ -52,6 +52,10 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : { this._animateToZoom = zoom; this._animatingZoom = true; + if (L.Draggable) { + L.Draggable._disabled = true; + } + var transform = L.DomUtil.TRANSFORM, tileBg = this._tileBg; @@ -146,6 +150,10 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : { L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim'); this._animatingZoom = false; + + if (L.Draggable) { + L.Draggable._disabled = false; + } }, _restoreTileFront: function () { diff --git a/src/map/handler/Map.TouchZoom.js b/src/map/handler/Map.TouchZoom.js index b74c468c..89f61423 100644 --- a/src/map/handler/Map.TouchZoom.js +++ b/src/map/handler/Map.TouchZoom.js @@ -32,6 +32,10 @@ L.Map.TouchZoom = L.Handler.extend({ this._centerOffset = viewCenter.subtract(this._startCenter); + if (map._panAnim) { + map._panAnim.stop(); + } + L.DomEvent .on(document, 'touchmove', this._onTouchMove, this) .on(document, 'touchend', this._onTouchEnd, this);