Merge pull request #6198 from oterral/flyTo
Fix sourceResolution value in view.animate
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user