Do not fire modifystart when nothing is being modified
This commit is contained in:
@@ -435,14 +435,17 @@ class Modify extends PointerInteraction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.featuresBeingModified_.getLength() === 0) {
|
||||||
this.dispatchEvent(
|
this.featuresBeingModified_ = null;
|
||||||
new ModifyEvent(
|
} else {
|
||||||
ModifyEventType.MODIFYSTART,
|
this.dispatchEvent(
|
||||||
this.featuresBeingModified_,
|
new ModifyEvent(
|
||||||
evt
|
ModifyEventType.MODIFYSTART,
|
||||||
)
|
this.featuresBeingModified_,
|
||||||
);
|
evt
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
clearUserProjection,
|
clearUserProjection,
|
||||||
setUserProjection,
|
setUserProjection,
|
||||||
} from '../../../../../src/ol/proj.js';
|
} from '../../../../../src/ol/proj.js';
|
||||||
import {doubleClick} from '../../../../../src/ol/events/condition.js';
|
import {doubleClick, never} from '../../../../../src/ol/events/condition.js';
|
||||||
import {getValues} from '../../../../../src/ol/obj.js';
|
import {getValues} from '../../../../../src/ol/obj.js';
|
||||||
|
|
||||||
describe('ol.interaction.Modify', function () {
|
describe('ol.interaction.Modify', function () {
|
||||||
@@ -853,6 +853,33 @@ describe('ol.interaction.Modify', function () {
|
|||||||
expect(listenerSpy.callCount).to.be(1);
|
expect(listenerSpy.callCount).to.be(1);
|
||||||
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
|
expect(feature.getGeometry().getCoordinates()[0]).to.have.length(5);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not fire `modifystart` when nothing is modified', function (done) {
|
||||||
|
const modify = new Modify({
|
||||||
|
features: new Collection(features),
|
||||||
|
insertVertexCondition: never,
|
||||||
|
});
|
||||||
|
map.addInteraction(modify);
|
||||||
|
|
||||||
|
let modifystart = false;
|
||||||
|
modify.on('modifystart', function () {
|
||||||
|
modifystart = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// try to add vertex
|
||||||
|
simulateEvent('pointermove', 40, -20, null, 0);
|
||||||
|
simulateEvent('pointerdown', 40, -20, null, 0);
|
||||||
|
simulateEvent('pointermove', 42, -30, null, 0);
|
||||||
|
simulateEvent('pointerdrag', 42, -30, null, 0);
|
||||||
|
simulateEvent('pointerup', 42, -30, null, 0);
|
||||||
|
simulateEvent('click', 42, -30, null, 0);
|
||||||
|
simulateEvent('singleclick', 42, -30, null, 0);
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
expect(modifystart).to.be(false);
|
||||||
|
done();
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('handle feature change', function () {
|
describe('handle feature change', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user