Make keyboard zoom animation duration configurable
This commit is contained in:
@@ -306,6 +306,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} ol.interaction.KeyboardZoomOptions
|
* @typedef {Object} ol.interaction.KeyboardZoomOptions
|
||||||
|
* @property {number|undefined} duration Animation duration. Default is 100ms.
|
||||||
* @property {ol.interaction.ConditionType|undefined} condition A conditional
|
* @property {ol.interaction.ConditionType|undefined} condition A conditional
|
||||||
* modifier (i.e. Shift key) that determines if the interaction is active
|
* modifier (i.e. Shift key) that determines if the interaction is active
|
||||||
* or not, default is no modifiers.
|
* or not, default is no modifiers.
|
||||||
|
|||||||
@@ -9,12 +9,6 @@ goog.require('ol.interaction.Interaction');
|
|||||||
goog.require('ol.interaction.condition');
|
goog.require('ol.interaction.condition');
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {number} Zoom duration.
|
|
||||||
*/
|
|
||||||
ol.interaction.KEYBOARD_ZOOM_DURATION = 100;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the user to zoom the map using keyboard + and -.
|
* Allows the user to zoom the map using keyboard + and -.
|
||||||
@@ -41,6 +35,12 @@ ol.interaction.KeyboardZoom = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.delta_ = goog.isDef(options.delta) ? options.delta : 1;
|
this.delta_ = goog.isDef(options.delta) ? options.delta : 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.duration_ = goog.isDef(options.duration) ? options.duration : 100;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction);
|
goog.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction);
|
||||||
|
|
||||||
@@ -62,8 +62,8 @@ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
|
|||||||
map.requestRenderFrame();
|
map.requestRenderFrame();
|
||||||
// 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, undefined,
|
ol.interaction.Interaction.zoomByDelta(
|
||||||
ol.interaction.KEYBOARD_ZOOM_DURATION);
|
map, view, delta, undefined, this.duration_);
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
stopEvent = true;
|
stopEvent = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user