Adds option to View for using larger resolution value when clamping

This commit is contained in:
Jeremy Smith
2020-01-29 14:36:56 +10:00
parent 2652c1a30d
commit 4151e86c0a
3 changed files with 51 additions and 12 deletions

View File

@@ -380,6 +380,32 @@ describe('ol.View', function() {
expect(constraint(1, 0, size)).to.be(5);
});
it('accepts extent and uses the smallest value', function() {
const constraint = getConstraint({
extent: [0, 0, 4000, 6000]
});
expect(constraint(1000, 0, size)).to.be(20);
expect(constraint(500, 0, size)).to.be(20);
expect(constraint(100, 0, size)).to.be(20);
expect(constraint(50, 0, size)).to.be(20);
expect(constraint(10, 0, size)).to.be(10);
expect(constraint(1, 0, size)).to.be(1);
});
it('accepts extent and largerResolutionConstraint and uses the larger value', function() {
const constraint = getConstraint({
extent: [0, 0, 4000, 6000],
largerResolutionConstraint: true
});
expect(constraint(1000, 0, size)).to.be(30);
expect(constraint(500, 0, size)).to.be(30);
expect(constraint(100, 0, size)).to.be(30);
expect(constraint(50, 0, size)).to.be(30);
expect(constraint(10, 0, size)).to.be(10);
expect(constraint(1, 0, size)).to.be(1);
});
});
describe('overspecified options (prefers resolution)', function() {