Move ol.DRAGZOOM_ANIMATION_DURATION const to a constructor option

This commit is contained in:
Frederic Junod
2015-04-13 14:59:39 +02:00
parent 3eb22559d6
commit 2fcdc48d20
3 changed files with 16 additions and 8 deletions
+9
View File
@@ -2286,6 +2286,7 @@ olx.interaction.DragRotateOptions.prototype.condition;
/** /**
* @typedef {{condition: (ol.events.ConditionType|undefined), * @typedef {{condition: (ol.events.ConditionType|undefined),
* duration: (number|undefined),
* style: ol.style.Style}} * style: ol.style.Style}}
* @api * @api
*/ */
@@ -2302,6 +2303,14 @@ olx.interaction.DragZoomOptions;
olx.interaction.DragZoomOptions.prototype.condition; olx.interaction.DragZoomOptions.prototype.condition;
/**
* Animation duration in milliseconds. Default is `200`.
* @type {number|undefined}
* @api
*/
olx.interaction.DragZoomOptions.prototype.duration;
/** /**
* Style for the box. * Style for the box.
* @type {ol.style.Style} * @type {ol.style.Style}
+7 -2
View File
@@ -1,7 +1,6 @@
goog.provide('ol.interaction.DragZoom'); goog.provide('ol.interaction.DragZoom');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.interaction.DragBox'); goog.require('ol.interaction.DragBox');
@@ -28,6 +27,12 @@ ol.interaction.DragZoom = function(opt_options) {
var condition = goog.isDef(options.condition) ? var condition = goog.isDef(options.condition) ?
options.condition : ol.events.condition.shiftKeyOnly; options.condition : ol.events.condition.shiftKeyOnly;
/**
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 200;
/** /**
* @private * @private
* @type {ol.style.Style} * @type {ol.style.Style}
@@ -61,5 +66,5 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
goog.asserts.assert(goog.isDef(size), 'size should be defined'); goog.asserts.assert(goog.isDef(size), 'size should be defined');
ol.interaction.Interaction.zoom(map, view, ol.interaction.Interaction.zoom(map, view,
view.getResolutionForExtent(extent, size), view.getResolutionForExtent(extent, size),
center, ol.DRAGZOOM_ANIMATION_DURATION); center, this.duration_);
}; };
-6
View File
@@ -60,12 +60,6 @@ ol.DRAGROTATEANDZOOM_ANIMATION_DURATION = 400;
ol.DRAGROTATE_ANIMATION_DURATION = 250; ol.DRAGROTATE_ANIMATION_DURATION = 250;
/**
* @define {number} Drag-zoom animation duration.
*/
ol.DRAGZOOM_ANIMATION_DURATION = 200;
/** /**
* @define {number} Hysteresis pixels. * @define {number} Hysteresis pixels.
*/ */