From 8c9153ffcae5b141e07088e8240723597055bdbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 8 Apr 2013 12:51:29 +0200 Subject: [PATCH] ZoomSlider animates to final resolution --- src/ol/control/zoomslidercontrol.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/ol/control/zoomslidercontrol.js b/src/ol/control/zoomslidercontrol.js index ae565475b5..4738a9ff4c 100644 --- a/src/ol/control/zoomslidercontrol.js +++ b/src/ol/control/zoomslidercontrol.js @@ -18,6 +18,12 @@ goog.require('ol.control.Control'); goog.require('ol.css'); +/** + * @define {number} Animation duration. + */ +ol.control.ZOOMSLIDER_ANIMATION_DURATION = 200; + + /** * @constructor @@ -248,9 +254,14 @@ ol.control.ZoomSlider.prototype.handleSliderChange_ = function(e) { var map = this.getMap(), amountDragged = this.amountDragged_(e), res = this.resolutionForAmount_(amountDragged); - if (res !== this.currentResolution_) { - this.currentResolution_ = res; - map.getView().setResolution(res); + if (e.type === goog.fx.Dragger.EventType.DRAG) { + if (res !== this.currentResolution_) { + this.currentResolution_ = res; + map.getView().zoomWithoutConstraints(map, res); + } + } else { + map.getView().zoom(map, this.currentResolution_, undefined, + ol.control.ZOOMSLIDER_ANIMATION_DURATION); } };