Skip to content

Commit

Permalink
stop pan key event even when pan anim is in progress (Leaflet#6231)
Browse files Browse the repository at this point in the history
When pressing pan key multiple times while pan animation is in progress, `stop` function isn't invoked.
This led to document scroll (if document is scrollable)

This commit fixes the issue to stop pan key event even when pan animation is in progress.
  • Loading branch information
cherniavskii authored and mourner committed Jul 9, 2018
1 parent d7f91d9 commit b507e21
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/map/handler/Map.Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,18 @@ export var Keyboard = Handler.extend({
offset;

if (key in this._panKeys) {
if (!map._panAnim || !map._panAnim._inProgress) {
offset = this._panKeys[key];
if (e.shiftKey) {
offset = toPoint(offset).multiplyBy(3);
}

if (map._panAnim && map._panAnim._inProgress) { return; }
map.panBy(offset);

offset = this._panKeys[key];
if (e.shiftKey) {
offset = toPoint(offset).multiplyBy(3);
if (map.options.maxBounds) {
map.panInsideBounds(map.options.maxBounds);
}
}

map.panBy(offset);

if (map.options.maxBounds) {
map.panInsideBounds(map.options.maxBounds);
}

} else if (key in this._zoomKeys) {
map.setZoom(map.getZoom() + (e.shiftKey ? 3 : 1) * this._zoomKeys[key]);

Expand Down

0 comments on commit b507e21

Please sign in to comment.