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,15 +211,17 @@ L.Map = L.Class.extend({
var offset = oldSize._subtract(this.getSize())._divideBy(2)._round(); var offset = oldSize._subtract(this.getSize())._divideBy(2)._round();
if (animate === true) { if ((offset.x !== 0) || (offset.y !== 0)) {
this.panBy(offset); if (animate === true) {
} else { this.panBy(offset);
this._rawPanBy(offset); } else {
this._rawPanBy(offset);
this.fire('move'); this.fire('move');
clearTimeout(this._sizeTimer); clearTimeout(this._sizeTimer);
this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200); this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
}
} }
return this; return this;
}, },

View File

@ -32,7 +32,7 @@ L.Map.include({
return this; return this;
}, },
panBy: function (offset, duration, easeLinearity) { panBy: function (offset, duration, easeLinearity, moving) {
offset = L.point(offset); offset = L.point(offset);
if (!(offset.x || offset.y)) { if (!(offset.x || offset.y)) {
@ -48,7 +48,9 @@ L.Map.include({
}, this); }, this);
} }
this.fire('movestart'); if (moving !== true) {
this.fire('movestart');
}
L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim'); 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]; noInertia = !options.inertia || delay > options.inertiaThreshold || !this._positions[0];
map.fire('dragend');
if (noInertia) { if (noInertia) {
map.fire('moveend'); map.fire('moveend');
@ -130,12 +132,10 @@ L.Map.Drag = L.Handler.extend({
offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round(); offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round();
L.Util.requestAnimFrame(function () { L.Util.requestAnimFrame(function () {
map.panBy(offset, decelerationDuration, ease); map.panBy(offset, decelerationDuration, ease, true);
}); });
} }
map.fire('dragend');
if (options.maxBounds) { if (options.maxBounds) {
// TODO predrag validation instead of animation // TODO predrag validation instead of animation
L.Util.requestAnimFrame(this._panInsideMaxBounds, map, true, map._container); L.Util.requestAnimFrame(this._panInsideMaxBounds, map, true, map._container);