Make mouse wheel zoom animation duration configurable
This commit is contained in:
@@ -313,6 +313,11 @@
|
|||||||
* @property {number|undefined} delta The amount to zoom on each key press.
|
* @property {number|undefined} delta The amount to zoom on each key press.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ol.interaction.MouseWheelZoomOptions
|
||||||
|
* @property {number|undefined} duration Animation duration. Default is 250ms.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} ol.interaction.SelectOptions
|
* @typedef {Object} ol.interaction.SelectOptions
|
||||||
* @property {ol.interaction.ConditionType|undefined} addCondition A conditional
|
* @property {ol.interaction.ConditionType|undefined} addCondition A conditional
|
||||||
|
|||||||
@@ -10,12 +10,6 @@ goog.require('ol.Coordinate');
|
|||||||
goog.require('ol.interaction.Interaction');
|
goog.require('ol.interaction.Interaction');
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @define {number} Animation duration.
|
|
||||||
*/
|
|
||||||
ol.interaction.MOUSEWHEELZOOM_ANIMATION_DURATION = 250;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @define {number} Maximum delta.
|
* @define {number} Maximum delta.
|
||||||
*/
|
*/
|
||||||
@@ -33,8 +27,11 @@ ol.interaction.MOUSEWHEELZOOM_TIMEOUT_DURATION = 80;
|
|||||||
* Allows the user to zoom the map by scrolling the mouse wheel.
|
* Allows the user to zoom the map by scrolling the mouse wheel.
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.interaction.Interaction}
|
* @extends {ol.interaction.Interaction}
|
||||||
|
* @param {ol.interaction.MouseWheelZoomOptions=} opt_options Options.
|
||||||
*/
|
*/
|
||||||
ol.interaction.MouseWheelZoom = function() {
|
ol.interaction.MouseWheelZoom = function(opt_options) {
|
||||||
|
|
||||||
|
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||||
|
|
||||||
goog.base(this);
|
goog.base(this);
|
||||||
|
|
||||||
@@ -44,6 +41,12 @@ ol.interaction.MouseWheelZoom = function() {
|
|||||||
*/
|
*/
|
||||||
this.delta_ = 0;
|
this.delta_ = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {?ol.Coordinate}
|
* @type {?ol.Coordinate}
|
||||||
@@ -113,7 +116,7 @@ ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
|
|||||||
|
|
||||||
map.requestRenderFrame();
|
map.requestRenderFrame();
|
||||||
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
||||||
ol.interaction.MOUSEWHEELZOOM_ANIMATION_DURATION);
|
this.duration_);
|
||||||
|
|
||||||
this.delta_ = 0;
|
this.delta_ = 0;
|
||||||
this.lastAnchor_ = null;
|
this.lastAnchor_ = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user