diff --git a/src/ol/animation.js b/src/ol/animation.js index 582c7c5ad0..4049186bb8 100644 --- a/src/ol/animation.js +++ b/src/ol/animation.js @@ -1,10 +1,10 @@ // FIXME works for View2D only +// FIXME dependency on ol.View2D suppressed to prevent dependency loop goog.provide('ol.animation'); goog.require('goog.fx.easing'); goog.require('ol.PreRenderFunction'); -goog.require('ol.View2D'); goog.require('ol.easing'); diff --git a/src/ol/view2d.js b/src/ol/view2d.js index e7cad27ed3..0ea5977c43 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -12,6 +12,7 @@ goog.require('ol.Projection'); goog.require('ol.ResolutionConstraint'); goog.require('ol.RotationConstraint'); goog.require('ol.View'); +goog.require('ol.animation'); /** @@ -289,9 +290,16 @@ ol.View2D.prototype.zoom_ = function(map, resolution, opt_anchor) { * @param {ol.Map} map Map. * @param {number} delta Delta from previous zoom level. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. + * @param {number=} opt_duration Duration. */ -ol.View2D.prototype.zoom = function(map, delta, opt_anchor) { - var resolution = this.constraints_.resolution(this.getResolution(), delta); +ol.View2D.prototype.zoom = function(map, delta, opt_anchor, opt_duration) { + var currentResolution = this.getResolution(); + if (goog.isDef(currentResolution) && goog.isDef(opt_duration)) { + map.requestRenderFrame(); + map.addPreRenderFunction(ol.animation.createZoomFrom( + currentResolution, opt_duration)); + } + var resolution = this.constraints_.resolution(currentResolution, delta); this.zoom_(map, resolution, opt_anchor); };