diff --git a/examples/animation.js b/examples/animation.js index 9e2e9544dd..18146dadd5 100644 --- a/examples/animation.js +++ b/examples/animation.js @@ -72,7 +72,7 @@ document.getElementById('rotate-right').addEventListener('click', function() { document.getElementById('rotate-around-rome').addEventListener('click', function() { view.animate({ rotation: view.getRotation() + 2 * Math.PI, - rotationAnchor: rome + anchor: rome }); }); diff --git a/src/ol/view.js b/src/ol/view.js index 8acb24b52e..8f7ae82675 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -313,15 +313,13 @@ ol.View.prototype.updateAnimations_ = function() { this.set(ol.View.Property.RESOLUTION, resolution); } if (animation.sourceRotation !== undefined) { - var rotationDelta = progress * (animation.targetRotation - animation.sourceRotation); - this.set(ol.View.Property.ROTATION, animation.sourceRotation + rotationDelta); + var rotation = animation.sourceRotation + + progress * (animation.targetRotation - animation.sourceRotation); if (animation.anchor) { - var center = this.getCenter().slice(); - ol.coordinate.sub(center, animation.anchor); - ol.coordinate.rotate(center, rotationDelta); - ol.coordinate.add(center, animation.anchor); - this.set(ol.View.Property.CENTER, center); + this.set(ol.View.Property.CENTER, + this.calculateCenterRotate(rotation, animation.anchor)); } + this.set(ol.View.Property.ROTATION, rotation); } more = true; }