Remove the vertex on ol.interaction.Modify deactivation

This commit is contained in:
Frederic Junod
2016-10-14 11:21:40 +02:00
parent 1311f65ece
commit e853f1ed2a
2 changed files with 28 additions and 0 deletions

View File

@@ -258,6 +258,18 @@ ol.interaction.Modify.prototype.removeFeatureSegmentData_ = function(feature) {
};
/**
* @inheritDoc
*/
ol.interaction.Modify.prototype.setActive = function(active) {
if (this.vertexFeature_ && !active) {
this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null;
}
ol.interaction.Pointer.prototype.setActive.call(this, active);
};
/**
* @inheritDoc
*/

View File

@@ -534,4 +534,20 @@ describe('ol.interaction.Modify', function() {
});
});
describe('#setActive', function() {
it('removes the vertexFeature of deactivation', function() {
var modify = new ol.interaction.Modify({
features: new ol.Collection(features)
});
map.addInteraction(modify);
expect(modify.vertexFeature_).to.be(null);
simulateEvent('pointermove', 10, -20, false, 0);
expect(modify.vertexFeature_).to.not.be(null);
modify.setActive(false);
expect(modify.vertexFeature_).to.be(null);
});
});
});