Fix stuttering of pan animation in some cases

This commit is contained in:
mourner 2012-02-24 16:53:22 +02:00
parent 8ad4f12cb9
commit 194425d24b
3 changed files with 12 additions and 7 deletions

2
dist/leaflet.css vendored
View File

@ -239,7 +239,7 @@ a.leaflet-active {
opacity: 1; opacity: 1;
} }
.leaflet-zoom-anim .leaflet-tile { .leaflet-zoom-anim .leaflet-tile, .leaflet-pan-anim .leaflet-tile {
-webkit-transition: none; -webkit-transition: none;
-moz-transition: none; -moz-transition: none;
-o-transition: none; -o-transition: none;

View File

@ -65,8 +65,8 @@ L.Transition = L.Transition.extend({
this.fire('start'); this.fire('start');
if (L.Transition.NATIVE) { if (L.Transition.NATIVE) {
//clearInterval(this._timer); clearInterval(this._timer);
//this._timer = setInterval(this._onFakeStep, this.options.fakeStepInterval); this._timer = setInterval(this._onFakeStep, this.options.fakeStepInterval);
} else { } else {
this._onTransitionEnd(); this._onTransitionEnd();
} }
@ -88,7 +88,7 @@ L.Transition = L.Transition.extend({
this.fire('step'); this.fire('step');
}, },
_onTransitionEnd: function () { _onTransitionEnd: function (e) {
if (this._inProgress) { if (this._inProgress) {
this._inProgress = false; this._inProgress = false;
clearInterval(this._timer); clearInterval(this._timer);
@ -96,7 +96,10 @@ L.Transition = L.Transition.extend({
this._el.style[L.Transition.PROPERTY] = 'none'; this._el.style[L.Transition.PROPERTY] = 'none';
this.fire('step'); this.fire('step');
this.fire('end');
if (e instanceof window.Event) {
this.fire('end');
}
} }
} }
}); });

View File

@ -32,10 +32,9 @@ L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : {
} }
if (!this._panTransition) { if (!this._panTransition) {
this._panTransition = new L.Transition(this._mapPane); this._panTransition = new L.Transition(this._mapPane);
this._panTransition.on('step', this._onPanTransitionStep, this); //this._panTransition.on('step', this._onPanTransitionStep, this);
this._panTransition.on('end', this._onPanTransitionEnd, this); this._panTransition.on('end', this._onPanTransitionEnd, this);
} }
@ -43,6 +42,8 @@ L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : {
this.fire('movestart'); this.fire('movestart');
this._mapPane.className += ' leaflet-pan-anim';
this._panTransition.run({ this._panTransition.run({
position: L.DomUtil.getPosition(this._mapPane).subtract(offset) position: L.DomUtil.getPosition(this._mapPane).subtract(offset)
}); });
@ -55,6 +56,7 @@ L.Map.include(!(L.Transition && L.Transition.implemented()) ? {} : {
}, },
_onPanTransitionEnd: function () { _onPanTransitionEnd: function () {
this._mapPane.className = this._mapPane.className.replace(/ leaflet-pan-anim/g, '');
this.fire('moveend'); this.fire('moveend');
}, },