diff --git a/src/ol/view.js b/src/ol/view.js index aa8185f69d..61b4640ee9 100644 --- a/src/ol/view.js +++ b/src/ol/view.js @@ -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); diff --git a/test/spec/ol/view.test.js b/test/spec/ol/view.test.js index 04517fc93b..ba10e3019b 100644 --- a/test/spec/ol/view.test.js +++ b/test/spec/ol/view.test.js @@ -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],