Skip to content

Commit

Permalink
Merge pull request #6198 from oterral/flyTo
Browse files Browse the repository at this point in the history
Fix sourceResolution value in view.animate
  • Loading branch information
tschaub committed Dec 3, 2016
2 parents fdec14c + 9eda6df commit c04a011
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ol/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ ol.View.prototype.animate = function(var_args) {
this.maxResolution_, options.zoom - this.minZoom_, 0);
resolution = animation.targetResolution;
} else if (options.resolution) {
animation.sourceResolution = this.getResolution();
animation.sourceResolution = resolution;
animation.targetResolution = options.resolution;
resolution = animation.targetResolution;
}
Expand Down
51 changes: 51 additions & 0 deletions test/spec/ol/view.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,57 @@ describe('ol.View', function() {

});

it('completes complex animation using resolution', function(done) {

var view = new ol.View({
center: [0, 0],
resolution: 2
});

var calls = 0;

function onAnimateEnd() {
if (calls == 2) {
expect(view.getAnimating()).to.be(false);
done();
}
}

view.animate({
center: [100, 100],
duration: 50
}, function() {
++calls;
expect(view.getCenter()).to.eql([100, 100]);
onAnimateEnd();
});

view.animate({
resolution: 2000,
duration: 25
},{
resolution: 2,
duration: 25
}, function() {
++calls;
expect(view.getResolution()).to.roughlyEqual(2, 1e-8);
onAnimateEnd();
});

setTimeout(function() {
expect(view.getResolution() > 2).to.be(true);
expect(view.getResolution() < 2000).to.be(true);
expect(view.getAnimating()).to.be(true);
}, 10);

setTimeout(function() {
expect(view.getResolution() > 2).to.be(true);
expect(view.getResolution() < 2000).to.be(true);
expect(view.getAnimating()).to.be(true);
}, 40);

});

});

describe('#cancelAnimations()', function() {
Expand Down

0 comments on commit c04a011

Please sign in to comment.