diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 98203a7b44..797bd1e942 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -343,6 +343,11 @@ * @property {number|undefined} threshold Minimal angle to start a rotation. */ +/** + * @typedef {Object} ol.interaction.TouchZoomOptions + * @property {number|undefined} duration Animation duration. Default is 400ms. + */ + /** * @typedef {Object} ol.layer.BaseOptions * @property {number|undefined} brightness Brightness. diff --git a/src/ol/interaction/touchzoominteraction.js b/src/ol/interaction/touchzoominteraction.js index 2591f0b0d4..8d1ece062b 100644 --- a/src/ol/interaction/touchzoominteraction.js +++ b/src/ol/interaction/touchzoominteraction.js @@ -9,20 +9,17 @@ goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Touch'); -/** - * @define {number} Animation duration. - */ -ol.interaction.TOUCHZOOM_ANIMATION_DURATION = 400; - - /** * Allows the user to zoom the map by pinching with two fingers * on a touch screen. * @constructor * @extends {ol.interaction.Touch} + * @param {ol.interaction.TouchZoomOptions=} opt_options Options. */ -ol.interaction.TouchZoom = function() { +ol.interaction.TouchZoom = function(opt_options) { + + var options = goog.isDef(opt_options) ? opt_options : {}; goog.base(this); @@ -32,6 +29,12 @@ ol.interaction.TouchZoom = function() { */ this.anchor_ = null; + /** + * @private + * @type {number} + */ + this.duration_ = goog.isDef(options.duration) ? options.duration : 400; + /** * @private * @type {number|undefined} @@ -107,7 +110,7 @@ ol.interaction.TouchZoom.prototype.handleTouchEnd = // Direction is > 0 if pinching out, and < 0 if pinching in. var direction = this.lastScaleDelta_ - 1; ol.interaction.Interaction.zoom(map, view, view2DState.resolution, - this.anchor_, ol.interaction.TOUCHZOOM_ANIMATION_DURATION, direction); + this.anchor_, this.duration_, direction); return false; } else { return true;