Merge pull request #6930 from openlayers/translate_no_map

Handle setActive(false) on an interaction without map
This commit is contained in:
Frédéric Junod
2017-06-20 08:30:45 +02:00
committed by GitHub
2 changed files with 18 additions and 6 deletions
+5 -6
View File
@@ -251,13 +251,12 @@ ol.interaction.Translate.prototype.handleActiveChanged_ = function() {
ol.interaction.Translate.prototype.updateState_ = function(oldMap) { ol.interaction.Translate.prototype.updateState_ = function(oldMap) {
var map = this.getMap(); var map = this.getMap();
var active = this.getActive(); var active = this.getActive();
if ((!map || !active)) { if (!map || !active) {
if (!map) { map = map || oldMap;
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');
} }
}; };
@@ -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() { describe('moving features, with features option', function() {
var translate; var translate;