Animate keyboard pan

This commit is contained in:
Tom Payne
2013-03-07 19:57:07 +01:00
parent 3d37ba7666
commit cd37031456

View File

@@ -9,6 +9,12 @@ goog.require('ol.View2D');
goog.require('ol.interaction.Interaction');
/**
* @define {number} Pan duration.
*/
ol.interaction.KEYBOARD_PAN_DURATION = 100;
/**
* @constructor
@@ -60,10 +66,8 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
} else {
deltaY = mapUnitsDelta;
}
var oldCenter = view.getCenter();
var newCenter = new ol.Coordinate(
oldCenter.x + deltaX, oldCenter.y + deltaY);
view.setCenter(newCenter);
view.pan(map, new ol.Coordinate(deltaX, deltaY),
ol.interaction.KEYBOARD_PAN_DURATION);
keyEvent.preventDefault();
mapBrowserEvent.preventDefault();
}