Use the animating hint

This commit is contained in:
Tim Schaub
2016-11-06 08:55:19 -07:00
parent f6ad883db6
commit da8eb97f54
2 changed files with 74 additions and 16 deletions

View File

@@ -372,6 +372,72 @@ describe('ol.View', function() {
view.setCenter([1, 2]); // interrupt the animation
});
it('properly sets the ANIMATING hint', function(done) {
var view = new ol.View({
center: [0, 0],
zoom: 0,
rotation: 0
});
var count = 3;
function decrement() {
--count;
if (count === 0) {
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(0);
done();
}
}
view.animate({
center: [1, 2],
duration: 25
}, decrement);
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(1);
view.animate({
zoom: 1,
duration: 25
}, decrement);
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(2);
view.animate({
rotate: Math.PI,
duration: 25
}, decrement);
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(3);
});
it('clears the ANIMATING hint when animations are cancelled', function() {
var view = new ol.View({
center: [0, 0],
zoom: 0,
rotation: 0
});
view.animate({
center: [1, 2],
duration: 25
});
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(1);
view.animate({
zoom: 1,
duration: 25
});
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(2);
view.animate({
rotate: Math.PI,
duration: 25
});
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(3);
// cancel animations
view.setCenter([10, 20]);
expect(view.getHints()[ol.View.Hint.ANIMATING]).to.be(0);
});
});
describe('#getResolutions', function() {