diff --git a/src/ol/interaction/extent.js b/src/ol/interaction/extent.js index 2950851753..5c8faff478 100644 --- a/src/ol/interaction/extent.js +++ b/src/ol/interaction/extent.js @@ -76,10 +76,6 @@ ol.interaction.Extent = function(opt_options) { opt_options = {}; } - if (opt_options.extent) { - this.setExtent(opt_options.extent); - } - /* Inherit ol.interaction.Pointer */ ol.interaction.Pointer.call(this, { handleDownEvent: ol.interaction.Extent.handleDownEvent_, @@ -117,6 +113,10 @@ ol.interaction.Extent = function(opt_options) { updateWhileAnimating: true, updateWhileInteracting: true }); + + if (opt_options.extent) { + this.setExtent(opt_options.extent); + } }; ol.inherits(ol.interaction.Extent, ol.interaction.Pointer); diff --git a/test/spec/ol/interaction/extent.test.js b/test/spec/ol/interaction/extent.test.js index f32f010e4b..acdb85865a 100644 --- a/test/spec/ol/interaction/extent.test.js +++ b/test/spec/ol/interaction/extent.test.js @@ -72,6 +72,19 @@ describe('ol.interaction.Extent', function() { event.pointerEvent.pointerId = 1; 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() { it('snap to vertex works', function() { interaction.setExtent([-50, -50, 50, 50]);