Complete animations at target values
This commit is contained in:
+8
-6
@@ -323,18 +323,20 @@ ol.View.prototype.updateAnimations_ = function() {
|
|||||||
var y = y0 + progress * (y1 - y0);
|
var y = y0 + progress * (y1 - y0);
|
||||||
this.set(ol.ViewProperty.CENTER, [x, y]);
|
this.set(ol.ViewProperty.CENTER, [x, y]);
|
||||||
}
|
}
|
||||||
if (animation.sourceResolution) {
|
if (animation.sourceResolution && animation.targetResolution) {
|
||||||
var resolution = animation.sourceResolution +
|
var resolution = progress === 1 ?
|
||||||
progress * (animation.targetResolution - animation.sourceResolution);
|
animation.targetResolution :
|
||||||
|
animation.sourceResolution + progress * (animation.targetResolution - animation.sourceResolution);
|
||||||
if (animation.anchor) {
|
if (animation.anchor) {
|
||||||
this.set(ol.ViewProperty.CENTER,
|
this.set(ol.ViewProperty.CENTER,
|
||||||
this.calculateCenterZoom(resolution, animation.anchor));
|
this.calculateCenterZoom(resolution, animation.anchor));
|
||||||
}
|
}
|
||||||
this.set(ol.ViewProperty.RESOLUTION, resolution);
|
this.set(ol.ViewProperty.RESOLUTION, resolution);
|
||||||
}
|
}
|
||||||
if (animation.sourceRotation !== undefined) {
|
if (animation.sourceRotation !== undefined && animation.targetRotation !== undefined) {
|
||||||
var rotation = animation.sourceRotation +
|
var rotation = progress === 1 ?
|
||||||
progress * (animation.targetRotation - animation.sourceRotation);
|
animation.targetRotation :
|
||||||
|
animation.sourceRotation + progress * (animation.targetRotation - animation.sourceRotation);
|
||||||
if (animation.anchor) {
|
if (animation.anchor) {
|
||||||
this.set(ol.ViewProperty.CENTER,
|
this.set(ol.ViewProperty.CENTER,
|
||||||
this.calculateCenterRotate(rotation, animation.anchor));
|
this.calculateCenterRotate(rotation, animation.anchor));
|
||||||
|
|||||||
@@ -406,6 +406,26 @@ describe('ol.View', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('avoids going under minResolution', function(done) {
|
||||||
|
var maxZoom = 14;
|
||||||
|
var view = new ol.View({
|
||||||
|
center: [0, 0],
|
||||||
|
zoom: 0,
|
||||||
|
maxZoom: maxZoom
|
||||||
|
});
|
||||||
|
|
||||||
|
var minResolution = view.getMinResolution();
|
||||||
|
view.animate({
|
||||||
|
resolution: minResolution,
|
||||||
|
duration: 10
|
||||||
|
}, function(complete) {
|
||||||
|
expect(complete).to.be(true);
|
||||||
|
expect(view.getResolution()).to.be(minResolution);
|
||||||
|
expect(view.getZoom()).to.be(maxZoom);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('calls a callback when animation completes', function(done) {
|
it('calls a callback when animation completes', function(done) {
|
||||||
var view = new ol.View({
|
var view = new ol.View({
|
||||||
center: [0, 0],
|
center: [0, 0],
|
||||||
@@ -558,7 +578,7 @@ describe('ol.View', function() {
|
|||||||
duration: 25
|
duration: 25
|
||||||
}, function() {
|
}, function() {
|
||||||
expect(calls).to.be(1);
|
expect(calls).to.be(1);
|
||||||
expect(view.getZoom()).to.roughlyEqual(2, 1e-8);
|
expect(view.getZoom()).to.be(2);
|
||||||
expect(view.getAnimating()).to.be(false);
|
expect(view.getAnimating()).to.be(false);
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -599,7 +619,7 @@ describe('ol.View', function() {
|
|||||||
duration: 25
|
duration: 25
|
||||||
}, function() {
|
}, function() {
|
||||||
++calls;
|
++calls;
|
||||||
expect(view.getResolution()).to.roughlyEqual(2, 1e-8);
|
expect(view.getResolution()).to.be(2);
|
||||||
onAnimateEnd();
|
onAnimateEnd();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user