Normalize rotation to values between -180 and 180 degrees after animation

This commit is contained in:
Andreas Hocevar
2017-06-28 15:45:45 +02:00
parent cd4ed759ed
commit ee0eb8b1a0
2 changed files with 18 additions and 5 deletions

View File

@@ -494,7 +494,7 @@ describe('ol.View', function() {
});
});
it('takes the shortest angle to the target rotation', function(done) {
it('takes the shortest arc to the target rotation', function(done) {
var view = new ol.View({
center: [0, 0],
zoom: 0,
@@ -509,6 +509,21 @@ describe('ol.View', function() {
});
});
it('normalizes rotation to angles between -180 and 180 degrees after the anmiation', function(done) {
var view = new ol.View({
center: [0, 0],
zoom: 0,
rotation: Math.PI / 180 * 1
});
view.animate({
rotation: Math.PI / 180 * -181,
duration: 0
}, function() {
expect(view.getRotation()).to.roughlyEqual(Math.PI / 180 * 179, 1e-12);
done();
});
});
it('calls a callback when animation completes', function(done) {
var view = new ol.View({
center: [0, 0],