Make double click zoom animation duration configurable
This commit is contained in:
@@ -240,6 +240,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} ol.interaction.DoubleClickZoomOptions
|
* @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
|
* @property {number|undefined} delta The zoom delta applied on each double
|
||||||
* click, default is 1.
|
* click, default is 1.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,12 +8,6 @@ goog.require('ol.MapBrowserEvent.EventType');
|
|||||||
goog.require('ol.interaction.Interaction');
|
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.
|
* Allows the user to zoom by double-clicking on the map.
|
||||||
@@ -34,6 +28,12 @@ ol.interaction.DoubleClickZoom = function(opt_options) {
|
|||||||
|
|
||||||
goog.base(this);
|
goog.base(this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction);
|
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_;
|
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
|
||||||
// FIXME works for View2D only
|
// FIXME works for View2D only
|
||||||
var view = map.getView().getView2D();
|
var view = map.getView().getView2D();
|
||||||
ol.interaction.Interaction.zoomByDelta(map, view, delta, anchor,
|
ol.interaction.Interaction.zoomByDelta(
|
||||||
ol.interaction.DOUBLECLICKZOOM_ANIMATION_DURATION);
|
map, view, delta, anchor, this.duration_);
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
stopEvent = true;
|
stopEvent = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user