From 93b33589a1133784b4fc75bb3fb980a656626c92 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Mon, 7 Oct 2013 15:39:52 +0200 Subject: [PATCH] Make double click zoom animation duration configurable --- src/objectliterals.jsdoc | 1 + src/ol/interaction/doubleclickzoominteraction.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index a608544138..bee1954ac6 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -240,6 +240,7 @@ /** * @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 * click, default is 1. */ diff --git a/src/ol/interaction/doubleclickzoominteraction.js b/src/ol/interaction/doubleclickzoominteraction.js index 38c1427db5..f68a348c5d 100644 --- a/src/ol/interaction/doubleclickzoominteraction.js +++ b/src/ol/interaction/doubleclickzoominteraction.js @@ -8,12 +8,6 @@ goog.require('ol.MapBrowserEvent.EventType'); 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. @@ -34,6 +28,12 @@ ol.interaction.DoubleClickZoom = function(opt_options) { goog.base(this); + /** + * @private + * @type {number} + */ + this.duration_ = goog.isDef(options.duration) ? options.duration : 250; + }; 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_; // FIXME works for View2D only var view = map.getView().getView2D(); - ol.interaction.Interaction.zoomByDelta(map, view, delta, anchor, - ol.interaction.DOUBLECLICKZOOM_ANIMATION_DURATION); + ol.interaction.Interaction.zoomByDelta( + map, view, delta, anchor, this.duration_); mapBrowserEvent.preventDefault(); stopEvent = true; }