From 3b4bc0be2584aa1174626aef113830636c4b73be Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 13 Apr 2015 14:44:46 +0200 Subject: [PATCH] Move ol.KEYBOARD_PAN_DURATION const to a constructor option --- externs/olx.js | 9 +++++++++ src/ol/interaction/keyboardpaninteraction.js | 10 +++++++--- src/ol/ol.js | 6 ------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index ebf684f3b2..28fa457dce 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2385,6 +2385,7 @@ olx.interaction.DrawOptions.prototype.condition; /** * @typedef {{condition: (ol.events.ConditionType|undefined), + * duration: (number|undefined), * pixelDelta: (number|undefined)}} * @api */ @@ -2402,6 +2403,14 @@ olx.interaction.KeyboardPanOptions; olx.interaction.KeyboardPanOptions.prototype.condition; +/** + * Animation duration in milliseconds. Default is `100`. + * @type {number|undefined} + * @api + */ +olx.interaction.KeyboardPanOptions.prototype.duration; + + /** * Pixel The amount to pan on each key press. Default is `128` pixels. * @type {number|undefined} diff --git a/src/ol/interaction/keyboardpaninteraction.js b/src/ol/interaction/keyboardpaninteraction.js index d29e6e7425..029627f70c 100644 --- a/src/ol/interaction/keyboardpaninteraction.js +++ b/src/ol/interaction/keyboardpaninteraction.js @@ -4,7 +4,6 @@ goog.require('goog.asserts'); goog.require('goog.events.KeyCodes'); goog.require('goog.events.KeyHandler.EventType'); goog.require('goog.functions'); -goog.require('ol'); goog.require('ol.coordinate'); goog.require('ol.events.ConditionType'); goog.require('ol.events.condition'); @@ -45,6 +44,12 @@ ol.interaction.KeyboardPan = function(opt_options) { goog.functions.and(ol.events.condition.noModifierKeys, ol.events.condition.targetNotEditable); + /** + * @private + * @type {number} + */ + this.duration_ = goog.isDef(options.duration) ? options.duration : 100; + /** * @private * @type {number} @@ -89,8 +94,7 @@ ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) { } var delta = [deltaX, deltaY]; ol.coordinate.rotate(delta, viewState.rotation); - ol.interaction.Interaction.pan( - map, view, delta, ol.KEYBOARD_PAN_DURATION); + ol.interaction.Interaction.pan(map, view, delta, this.duration_); mapBrowserEvent.preventDefault(); stopEvent = true; } diff --git a/src/ol/ol.js b/src/ol/ol.js index 417a0cde6c..1ec7d5e5e3 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -170,12 +170,6 @@ ol.IS_LEGACY_IE = goog.userAgent.IE && !goog.userAgent.isVersionOrHigher('9.0') && goog.userAgent.VERSION !== ''; -/** - * @define {number} Keyboard pan duration. - */ -ol.KEYBOARD_PAN_DURATION = 100; - - /** * @define {number} The maximum size in pixels of atlas images. Default is * `-1`, meaning it is not used (and `ol.WEBGL_MAX_TEXTURE_SIZE` is