Run animations in series

This commit is contained in:
Tim Schaub
2016-11-06 10:06:58 -07:00
parent 337c6bb73e
commit 6f08498684
2 changed files with 32 additions and 0 deletions

View File

@@ -340,6 +340,9 @@ ol.View.prototype.updateAnimations_ = function() {
this.set(ol.View.Property.ROTATION, rotation);
}
more = true;
if (!animation.complete) {
break;
}
}
if (seriesComplete) {
this.setHint(ol.View.Hint.ANIMATING, -1);

View File

@@ -372,6 +372,35 @@ describe('ol.View', function() {
view.setCenter([1, 2]); // interrupt the animation
});
it('can run multiple animations in series', function(done) {
var view = new ol.View({
center: [0, 0],
zoom: 0
});
var checked = false;
view.animate({
zoom: 2,
duration: 25
}, {
center: [10, 10],
duration: 25
}, function(complete) {
expect(checked).to.be(true);
expect(view.getZoom()).to.roughlyEqual(2, 1e-5);
expect(view.getCenter()).to.eql([10, 10]);
expect(complete).to.be(true);
done();
});
setTimeout(function() {
expect(view.getCenter()).to.eql([0, 0]);
checked = true;
}, 10);
});
it('properly sets the ANIMATING hint', function(done) {
var view = new ol.View({
center: [0, 0],