Merge pull request #1374 from oslek/move-events

Move events
This commit is contained in:
Vladimir Agafonkin 2013-02-14 02:31:25 -08:00
commit d8ef52b1b1
3 changed files with 16 additions and 12 deletions

View File

@ -211,6 +211,7 @@ L.Map = L.Class.extend({
var offset = oldSize._subtract(this.getSize())._divideBy(2)._round();
if ((offset.x !== 0) || (offset.y !== 0)) {
if (animate === true) {
this.panBy(offset);
} else {
@ -221,6 +222,7 @@ L.Map = L.Class.extend({
clearTimeout(this._sizeTimer);
this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
}
}
return this;
},

View File

@ -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);
}
if (moving !== true) {
this.fire('movestart');
}
L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim');

View File

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