Allow to configure Extent interaction with an extent

This commit is contained in:
Andreas Hocevar
2017-07-28 12:28:06 +02:00
parent 8dbbe3ba5d
commit b0b68983f7
2 changed files with 17 additions and 4 deletions

View File

@@ -76,10 +76,6 @@ ol.interaction.Extent = function(opt_options) {
opt_options = {}; opt_options = {};
} }
if (opt_options.extent) {
this.setExtent(opt_options.extent);
}
/* Inherit ol.interaction.Pointer */ /* Inherit ol.interaction.Pointer */
ol.interaction.Pointer.call(this, { ol.interaction.Pointer.call(this, {
handleDownEvent: ol.interaction.Extent.handleDownEvent_, handleDownEvent: ol.interaction.Extent.handleDownEvent_,
@@ -117,6 +113,10 @@ ol.interaction.Extent = function(opt_options) {
updateWhileAnimating: true, updateWhileAnimating: true,
updateWhileInteracting: true updateWhileInteracting: true
}); });
if (opt_options.extent) {
this.setExtent(opt_options.extent);
}
}; };
ol.inherits(ol.interaction.Extent, ol.interaction.Pointer); ol.inherits(ol.interaction.Extent, ol.interaction.Pointer);

View File

@@ -72,6 +72,19 @@ describe('ol.interaction.Extent', function() {
event.pointerEvent.pointerId = 1; event.pointerEvent.pointerId = 1;
map.handleMapBrowserEvent(event); map.handleMapBrowserEvent(event);
} }
describe('Constructor', function() {
it('can be configured with an extent', function() {
expect(function() {
new ol.interaction.Extent({
extent: [-10, -10, 10, 10]
});
}).to.not.throwException();
});
});
describe('snap to vertex', function() { describe('snap to vertex', function() {
it('snap to vertex works', function() { it('snap to vertex works', function() {
interaction.setExtent([-50, -50, 50, 50]); interaction.setExtent([-50, -50, 50, 50]);