Skip to content

Commit

Permalink
Merge pull request #1374 from oslek/move-events
Browse files Browse the repository at this point in the history
Move events
  • Loading branch information
mourner committed Feb 14, 2013
2 parents b8b8d7b + c3ccf01 commit d8ef52b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,17 @@ L.Map = L.Class.extend({

var offset = oldSize._subtract(this.getSize())._divideBy(2)._round();

if (animate === true) {
this.panBy(offset);
} else {
this._rawPanBy(offset);
if ((offset.x !== 0) || (offset.y !== 0)) {
if (animate === true) {
this.panBy(offset);
} else {
this._rawPanBy(offset);

this.fire('move');
this.fire('move');

clearTimeout(this._sizeTimer);
this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
clearTimeout(this._sizeTimer);
this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
}
}
return this;
},
Expand Down
6 changes: 4 additions & 2 deletions src/map/anim/Map.PanAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -48,7 +48,9 @@ L.Map.include({
}, this);
}

this.fire('movestart');
if (moving !== true) {
this.fire('movestart');
}

L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim');

Expand Down
6 changes: 3 additions & 3 deletions src/map/handler/Map.Drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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);
Expand Down

0 comments on commit d8ef52b

Please sign in to comment.