diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index f94d5e950f..fd51b430a5 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -3,6 +3,8 @@ goog.provide('ol.interaction.Interaction'); 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 = 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]]); + } +}; diff --git a/src/ol/interaction/keyboardpaninteraction.js b/src/ol/interaction/keyboardpaninteraction.js index 24d86808b9..db7a273228 100644 --- a/src/ol/interaction/keyboardpaninteraction.js +++ b/src/ol/interaction/keyboardpaninteraction.js @@ -70,7 +70,8 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent = } var delta = [deltaX, deltaY]; 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(); mapBrowserEvent.preventDefault(); } diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 1c8164e067..6dd6b333b7 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -376,27 +376,6 @@ goog.exportProperty( 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 {number|undefined} rotation Rotation.