View / add support for viewport extent constraint
This introduces a breaking change: The `extent` view option now constrains the whole viewport and not just the view center. The option `constrainOnlyCenter` was added to keep the previous behaviour. Constraining the whole viewport and not only the view center means that the center and resolution constraints must be applied with a knowledge of the viewport size.
This commit is contained in:
@@ -132,6 +132,7 @@ describe('ol.interaction.Interaction', function() {
|
||||
const view = new View({
|
||||
center: [0, 0],
|
||||
extent: [-2.5, -2.5, 2.5, 2.5],
|
||||
constrainOnlyCenter: true,
|
||||
resolution: 1,
|
||||
resolutions: [4, 2, 1, 0.5, 0.25]
|
||||
});
|
||||
|
||||
@@ -45,7 +45,8 @@ describe('ol.View', function() {
|
||||
describe('with extent option', function() {
|
||||
it('gives a correct center constraint function', function() {
|
||||
const options = {
|
||||
extent: [0, 0, 1, 1]
|
||||
extent: [0, 0, 1, 1],
|
||||
constrainOnlyCenter: true
|
||||
};
|
||||
const fn = createCenterConstraint(options);
|
||||
expect(fn([0, 0])).to.eql([0, 0]);
|
||||
|
||||
Reference in New Issue
Block a user