Move animated zoom stopping in to the place it belongs
This commit is contained in:
parent
a5552f4ed4
commit
97598d4241
@ -201,6 +201,7 @@ L.Map = L.Evented.extend({
|
|||||||
|
|
||||||
//zoomPan
|
//zoomPan
|
||||||
L.Util.cancelAnimFrame(this._zoomPanFrame);
|
L.Util.cancelAnimFrame(this._zoomPanFrame);
|
||||||
|
//TODO: Need to fire zoomend if this was what was going on
|
||||||
|
|
||||||
//PosAnimation
|
//PosAnimation
|
||||||
if (this._panAnim && this._panAnim._inProgress) {
|
if (this._panAnim && this._panAnim._inProgress) {
|
||||||
@ -210,34 +211,8 @@ L.Map = L.Evented.extend({
|
|||||||
|
|
||||||
//zoomAnimation
|
//zoomAnimation
|
||||||
if (this._animatingZoom) {
|
if (this._animatingZoom) {
|
||||||
//Calculate _animateToZoom and _animateToCenter
|
this._stopAnimatedZoom();
|
||||||
var regex = /([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/;
|
|
||||||
var style = window.getComputedStyle(this._proxy._el);
|
|
||||||
var matches = style[L.DomUtil.TRANSFORM].match(regex);
|
|
||||||
//Assuming this works!
|
|
||||||
|
|
||||||
//debugger;
|
|
||||||
this._animateToZoom = this.getScaleZoom(parseFloat(matches[1]), 1);
|
|
||||||
var px = L.point(matches[2], matches[3]);
|
|
||||||
this._animateToCenter = this.unproject(px, this._animateToZoom);
|
|
||||||
|
|
||||||
console.log('stop', this._animateToCenter);
|
|
||||||
//this._animateToCenter.lat = parseFloat(matches[2]);
|
|
||||||
//this._animateToCenter.lng = parseFloat(matches[3]);
|
|
||||||
|
|
||||||
//L.Util.falseFn(map._panes.mapPane.offsetWidth);
|
|
||||||
|
|
||||||
this._onZoomTransitionEnd();
|
|
||||||
//L.Util.falseFn(map._panes.mapPane.offsetWidth);
|
|
||||||
|
|
||||||
//Something like _onZoomTransitionEnd, but not quite, we don't want the _resetView call
|
|
||||||
|
|
||||||
//Or if we set _animateToCenter and _animateToZoom then we can just call it
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO do a reset view
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO handler.addTo
|
// TODO handler.addTo
|
||||||
|
@ -87,6 +87,20 @@ L.Map.include(!zoomAnimated ? {} : {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_stopAnimatedZoom: function () {
|
||||||
|
|
||||||
|
//Extract zoom and translate from the matrix
|
||||||
|
var regex = /([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/,
|
||||||
|
style = window.getComputedStyle(this._proxy._el),
|
||||||
|
matches = style[L.DomUtil.TRANSFORM].match(regex),
|
||||||
|
px = L.point(matches[2], matches[3]);
|
||||||
|
|
||||||
|
//Replace the animation end variables with the current zoom/center
|
||||||
|
this._animateToZoom = this.getScaleZoom(parseFloat(matches[1]), 1);
|
||||||
|
this._animateToCenter = this.unproject(px, this._animateToZoom);
|
||||||
|
|
||||||
|
this._onZoomTransitionEnd();
|
||||||
|
},
|
||||||
_onZoomTransitionEnd: function () {
|
_onZoomTransitionEnd: function () {
|
||||||
|
|
||||||
this._animatingZoom = false;
|
this._animatingZoom = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user