Add insertVertexCondition to ol.interaction.Modify options
This commit is contained in:
@@ -559,6 +559,40 @@ describe('ol.interaction.Modify', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('insertVertexCondition', function() {
|
||||
it('calls the callback function', function() {
|
||||
var listenerSpy = sinon.spy(function(event) {
|
||||
return false;
|
||||
});
|
||||
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: new ol.Collection(features),
|
||||
insertVertexCondition: listenerSpy
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
var feature = features[0];
|
||||
|
||||
// move first vertex
|
||||
simulateEvent('pointermove', 0, 0, false, 0);
|
||||
simulateEvent('pointerdown', 0, 0, false, 0);
|
||||
simulateEvent('pointermove', -10, -10, false, 0);
|
||||
simulateEvent('pointerdrag', -10, -10, false, 0);
|
||||
simulateEvent('pointerup', -10, -10, false, 0);
|
||||
|
||||
expect(listenerSpy.callCount).to.be(0);
|
||||
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
|
||||
|
||||
// try to add vertex
|
||||
simulateEvent('pointerdown', 40, -20, false, 0);
|
||||
simulateEvent('pointerup', 40, -20, false, 0);
|
||||
simulateEvent('click', 40, -20, false, 0);
|
||||
simulateEvent('singleclick', 40, -20, false, 0);
|
||||
|
||||
expect(listenerSpy.callCount).to.be(1);
|
||||
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
|
||||
});
|
||||
});
|
||||
|
||||
describe('handle feature change', function() {
|
||||
var getListeners;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user