interaction/modify: Replace lastNewVertexPixel with ignoreNextSingleClick

The previous approach did not work on mobile devices where no `pointermove`
event is sent except from dragging.

Logic now is: Upon vertex creation due to `pointerdown` we will ignore
the next `singleclick` event unless there is a `pointerdrag` event, which will
not lead to a `singleclick` event following the vertex creation.

Resolves #3935
This commit is contained in:
Tobias Bieniek
2015-08-01 21:53:25 +02:00
parent b001a48567
commit 968c8aa34e
2 changed files with 42 additions and 7 deletions

View File

@@ -135,6 +135,34 @@ describe('ol.interaction.Modify', function() {
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(6);
});
it('single clicking on created vertex should delete it again', function() {
var modify = new ol.interaction.Modify({
features: new ol.Collection(features)
});
map.addInteraction(modify);
var feature = features[0];
expect(feature.getGeometry().getRevision()).to.equal(1);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
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(feature.getGeometry().getRevision()).to.equal(2);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(6);
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(feature.getGeometry().getRevision()).to.equal(3);
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
});
it('clicking with drag should add vertex and +r3', function() {
var modify = new ol.interaction.Modify({
features: new ol.Collection(features)