diff --git a/src/ol/interaction/translate.js b/src/ol/interaction/translate.js index af31884150..9e54d5a013 100644 --- a/src/ol/interaction/translate.js +++ b/src/ol/interaction/translate.js @@ -251,13 +251,12 @@ ol.interaction.Translate.prototype.handleActiveChanged_ = function() { ol.interaction.Translate.prototype.updateState_ = function(oldMap) { var map = this.getMap(); var active = this.getActive(); - if ((!map || !active)) { - if (!map) { - map = oldMap; + if (!map || !active) { + map = map || oldMap; + if (map) { + var elem = map.getViewport(); + elem.classList.remove('ol-grab', 'ol-grabbing'); } - - var elem = map.getViewport(); - elem.classList.remove('ol-grab', 'ol-grabbing'); } }; diff --git a/test/spec/ol/interaction/translate.test.js b/test/spec/ol/interaction/translate.test.js index 9f8a0c7d9c..20606222f5 100644 --- a/test/spec/ol/interaction/translate.test.js +++ b/test/spec/ol/interaction/translate.test.js @@ -143,6 +143,19 @@ describe('ol.interaction.Translate', function() { }); + describe('setActive', function() { + + it('works when the map is not set', function() { + var translate = new ol.interaction.Translate({ + features: features + }); + expect(translate.getActive()).to.be(true); + translate.setActive(false); + expect(translate.getActive()).to.be(false); + }); + + }); + describe('moving features, with features option', function() { var translate;