Make touch zoom animation duration configurable

This commit is contained in:
Tom Payne
2013-10-07 15:46:19 +02:00
parent 6c0d4cddad
commit b1ed63ebf8
2 changed files with 16 additions and 8 deletions

View File

@@ -343,6 +343,11 @@
* @property {number|undefined} threshold Minimal angle to start a rotation. * @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 * @typedef {Object} ol.layer.BaseOptions
* @property {number|undefined} brightness Brightness. * @property {number|undefined} brightness Brightness.

View File

@@ -9,20 +9,17 @@ goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Touch'); 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 * Allows the user to zoom the map by pinching with two fingers
* on a touch screen. * on a touch screen.
* @constructor * @constructor
* @extends {ol.interaction.Touch} * @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); goog.base(this);
@@ -32,6 +29,12 @@ ol.interaction.TouchZoom = function() {
*/ */
this.anchor_ = null; this.anchor_ = null;
/**
* @private
* @type {number}
*/
this.duration_ = goog.isDef(options.duration) ? options.duration : 400;
/** /**
* @private * @private
* @type {number|undefined} * @type {number|undefined}
@@ -107,7 +110,7 @@ ol.interaction.TouchZoom.prototype.handleTouchEnd =
// Direction is > 0 if pinching out, and < 0 if pinching in. // Direction is > 0 if pinching out, and < 0 if pinching in.
var direction = this.lastScaleDelta_ - 1; var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.zoom(map, view, view2DState.resolution, ol.interaction.Interaction.zoom(map, view, view2DState.resolution,
this.anchor_, ol.interaction.TOUCHZOOM_ANIMATION_DURATION, direction); this.anchor_, this.duration_, direction);
return false; return false;
} else { } else {
return true; return true;