Move ol.KEYBOARD_PAN_DURATION const to a constructor option

This commit is contained in:
Frederic Junod
2015-04-13 14:44:46 +02:00
parent 5dfa9e0a67
commit 3b4bc0be25
3 changed files with 16 additions and 9 deletions

View File

@@ -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}

View File

@@ -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;
}

View File

@@ -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