Support anchor for rotation animations
This commit is contained in:
@@ -72,7 +72,7 @@ document.getElementById('rotate-right').addEventListener('click', function() {
|
|||||||
document.getElementById('rotate-around-rome').addEventListener('click', function() {
|
document.getElementById('rotate-around-rome').addEventListener('click', function() {
|
||||||
view.animate({
|
view.animate({
|
||||||
rotation: view.getRotation() + 2 * Math.PI,
|
rotation: view.getRotation() + 2 * Math.PI,
|
||||||
rotationAnchor: rome
|
anchor: rome
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -313,15 +313,13 @@ ol.View.prototype.updateAnimations_ = function() {
|
|||||||
this.set(ol.View.Property.RESOLUTION, resolution);
|
this.set(ol.View.Property.RESOLUTION, resolution);
|
||||||
}
|
}
|
||||||
if (animation.sourceRotation !== undefined) {
|
if (animation.sourceRotation !== undefined) {
|
||||||
var rotationDelta = progress * (animation.targetRotation - animation.sourceRotation);
|
var rotation = animation.sourceRotation +
|
||||||
this.set(ol.View.Property.ROTATION, animation.sourceRotation + rotationDelta);
|
progress * (animation.targetRotation - animation.sourceRotation);
|
||||||
if (animation.anchor) {
|
if (animation.anchor) {
|
||||||
var center = this.getCenter().slice();
|
this.set(ol.View.Property.CENTER,
|
||||||
ol.coordinate.sub(center, animation.anchor);
|
this.calculateCenterRotate(rotation, 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.ROTATION, rotation);
|
||||||
}
|
}
|
||||||
more = true;
|
more = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user