Move pan function from View2D to Interaction
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
goog.provide('ol.interaction.Interaction');
|
goog.provide('ol.interaction.Interaction');
|
||||||
|
|
||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol.MapBrowserEvent');
|
||||||
|
goog.require('ol.animation');
|
||||||
|
goog.require('ol.easing');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -18,3 +20,26 @@ ol.interaction.Interaction = function() {
|
|||||||
*/
|
*/
|
||||||
ol.interaction.Interaction.prototype.handleMapBrowserEvent =
|
ol.interaction.Interaction.prototype.handleMapBrowserEvent =
|
||||||
goog.abstractMethod;
|
goog.abstractMethod;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Map} map Map.
|
||||||
|
* @param {ol.View2D} view View.
|
||||||
|
* @param {ol.Coordinate} delta Delta.
|
||||||
|
* @param {number=} opt_duration Duration.
|
||||||
|
*/
|
||||||
|
ol.interaction.Interaction.pan = function(
|
||||||
|
map, view, delta, opt_duration) {
|
||||||
|
var currentCenter = view.getCenter();
|
||||||
|
if (goog.isDef(currentCenter)) {
|
||||||
|
if (goog.isDef(opt_duration)) {
|
||||||
|
map.requestRenderFrame();
|
||||||
|
map.addPreRenderFunction(ol.animation.pan({
|
||||||
|
source: currentCenter,
|
||||||
|
duration: opt_duration,
|
||||||
|
easing: ol.easing.linear
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
view.setCenter([currentCenter[0] + delta[0], currentCenter[1] + delta[1]]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -70,7 +70,8 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
|||||||
}
|
}
|
||||||
var delta = [deltaX, deltaY];
|
var delta = [deltaX, deltaY];
|
||||||
ol.coordinate.rotate(delta, rotation);
|
ol.coordinate.rotate(delta, rotation);
|
||||||
view.pan(map, delta, ol.interaction.KEYBOARD_PAN_DURATION);
|
ol.interaction.Interaction.pan(
|
||||||
|
map, view, delta, ol.interaction.KEYBOARD_PAN_DURATION);
|
||||||
keyEvent.preventDefault();
|
keyEvent.preventDefault();
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,27 +376,6 @@ goog.exportProperty(
|
|||||||
ol.View2D.prototype.setRotation);
|
ol.View2D.prototype.setRotation);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Map} map Map.
|
|
||||||
* @param {ol.Coordinate} delta Delta.
|
|
||||||
* @param {number=} opt_duration Duration.
|
|
||||||
*/
|
|
||||||
ol.View2D.prototype.pan = function(map, delta, opt_duration) {
|
|
||||||
var currentCenter = this.getCenter();
|
|
||||||
if (goog.isDef(currentCenter)) {
|
|
||||||
if (goog.isDef(opt_duration)) {
|
|
||||||
map.requestRenderFrame();
|
|
||||||
map.addPreRenderFunction(ol.animation.pan({
|
|
||||||
source: currentCenter,
|
|
||||||
duration: opt_duration,
|
|
||||||
easing: ol.easing.linear
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
this.setCenter([currentCenter[0] + delta[0], currentCenter[1] + delta[1]]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Map} map Map.
|
* @param {ol.Map} map Map.
|
||||||
* @param {number|undefined} rotation Rotation.
|
* @param {number|undefined} rotation Rotation.
|
||||||
|
|||||||
Reference in New Issue
Block a user