Support anchor for rotation animations

This commit is contained in:
Tim Schaub
2016-11-05 20:49:15 -06:00
parent c95aa39dde
commit 3acfe79c78
2 changed files with 6 additions and 8 deletions

View File

@@ -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;
}