Improved performance when removing feature with only one Select

This commit is contained in:
Maximilian Krög
2020-09-28 00:23:26 +02:00
parent 705e328fa0
commit 65fc3ca2ca
+16 -18
View File
@@ -391,25 +391,23 @@ class Select extends Interaction {
* @private * @private
*/ */
restorePreviousStyle_(feature) { restorePreviousStyle_(feature) {
const key = getUid(feature); const interactions = this.getMap().getInteractions().getArray();
const selectInteractions = /** @type {Array<Select>} */ (this.getMap() for (let i = interactions.length - 1; i >= 0; --i) {
.getInteractions() const interaction = interactions[i];
.getArray() if (
.filter(function (interaction) { interaction !== this &&
return ( interaction instanceof Select &&
interaction instanceof Select && interaction.getStyle() &&
interaction.getStyle() && interaction.getFeatures().getArray().lastIndexOf(feature) !== -1
interaction.getFeatures().getArray().indexOf(feature) !== -1 ) {
); feature.setStyle(interaction.getStyle());
})); return;
if (selectInteractions.length > 0) { }
feature.setStyle(
selectInteractions[selectInteractions.length - 1].getStyle()
);
} else {
feature.setStyle(originalFeatureStyles[key]);
delete originalFeatureStyles[key];
} }
const key = getUid(feature);
feature.setStyle(originalFeatureStyles[key]);
delete originalFeatureStyles[key];
} }
/** /**