Merge pull request #9036 from ahocevar/modify-drag-segments

Remove drag segments of removed features
This commit is contained in:
Andreas Hocevar
2018-12-05 12:58:33 +01:00
committed by GitHub
2 changed files with 25 additions and 1 deletions

View File

@@ -392,7 +392,13 @@ class Modify extends PointerInteraction {
}
});
for (let i = nodesToRemove.length - 1; i >= 0; --i) {
rBush.remove(nodesToRemove[i]);
const nodeToRemove = nodesToRemove[i];
for (let j = this.dragSegments_.length - 1; j >= 0; --j) {
if (this.dragSegments_[j][0] === nodeToRemove) {
this.dragSegments_.splice(j, 1);
}
}
rBush.remove(nodeToRemove);
}
}

View File

@@ -696,6 +696,24 @@ describe('ol.interaction.Modify', function() {
});
});
describe('handle feature removal during down-up sequence', function() {
it('removes segment data of removed features from dragSegments_', function() {
const collection = new Collection(features);
const modify = new Modify({
features: collection
});
map.addInteraction(modify);
simulateEvent('pointermove', 0, 0, null, 0);
simulateEvent('pointerdown', 0, 0, null, 0);
simulateEvent('pointermove', -10, -10, null, 0);
simulateEvent('pointerdrag', -10, -10, null, 0);
collection.remove(features[0]);
expect(function() {
simulateEvent('pointerup', -10, -10, null, 0);
}).to.not.throwError();
});
});
describe('#setActive', function() {
it('removes the vertexFeature of deactivation', function() {
const modify = new Modify({