Make double click zoom animation duration configurable

This commit is contained in:
Tom Payne
2013-10-07 15:39:52 +02:00
parent 214e578333
commit 93b33589a1
2 changed files with 9 additions and 8 deletions

View File

@@ -240,6 +240,7 @@
/**
* @typedef {Object} ol.interaction.DoubleClickZoomOptions
* @property {number|undefined} duration Animation duration. Default is 250ms.
* @property {number|undefined} delta The zoom delta applied on each double
* click, default is 1.
*/

View File

@@ -8,12 +8,6 @@ goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.interaction.Interaction');
/**
* @define {number} Animation duration.
*/
ol.interaction.DOUBLECLICKZOOM_ANIMATION_DURATION = 250;
/**
* Allows the user to zoom by double-clicking on the map.
@@ -34,6 +28,12 @@ ol.interaction.DoubleClickZoom = function(opt_options) {
goog.base(this);
/**
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
};
goog.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction);
@@ -52,8 +52,8 @@ ol.interaction.DoubleClickZoom.prototype.handleMapBrowserEvent =
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
// FIXME works for View2D only
var view = map.getView().getView2D();
ol.interaction.Interaction.zoomByDelta(map, view, delta, anchor,
ol.interaction.DOUBLECLICKZOOM_ANIMATION_DURATION);
ol.interaction.Interaction.zoomByDelta(
map, view, delta, anchor, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}