Merge pull request #6198 from oterral/flyTo

Fix sourceResolution value in view.animate
This commit is contained in:
Tim Schaub
2016-12-02 23:07:30 -08:00
committed by GitHub
2 changed files with 52 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -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() {