From 33eb13d73b80d630e371efbe78ba99d90a9d0f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 20:29:18 +0100 Subject: [PATCH] Make animating rotation possible --- src/ol/view2d.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 77062aad97..4662678d3b 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -259,8 +259,28 @@ goog.exportProperty( * @param {ol.Map} map Map. * @param {number|undefined} rotation Rotation. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. + * @param {number=} opt_duration Duration. */ -ol.View2D.prototype.rotate = function(map, rotation, opt_anchor) { +ol.View2D.prototype.rotate = + function(map, rotation, opt_anchor, opt_duration) { + var currentRotation = this.getRotation(); + var currentCenter = this.getCenter(); + if (goog.isDef(currentRotation) && goog.isDef(currentCenter) && + goog.isDef(opt_duration)) { + map.requestRenderFrame(); + map.addPreRenderFunction(ol.animation.rotate({ + rotation: currentRotation, + duration: opt_duration, + easing: goog.fx.easing.easeOut + })); + if (goog.isDef(opt_anchor)) { + map.addPreRenderFunction(ol.animation.pan({ + source: currentCenter, + duration: opt_duration, + easing: goog.fx.easing.easeOut + })); + } + } rotation = this.constraints_.rotation(rotation, 0); this.rotateNoConstraint(map, rotation, opt_anchor); };