fixed glitches with zooming on pan animation and panning on zoom animation

This commit is contained in:
Vladimir Agafonkin 2012-08-13 15:41:20 +03:00
parent fd22f9f88a
commit 9625cdbbb9
5 changed files with 25 additions and 5 deletions

View File

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

View File

@ -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');
}

View File

@ -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));

View File

@ -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 () {

View File

@ -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);