Skip to content

Commit

Permalink
chore: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
oterral committed May 2, 2024
1 parent 7d3093f commit 5b59c54
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/control/cad.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class CadControl extends Control {
getClosestFeatures(coordinate, nbFeatures) {
const editFeature = this.editor.getEditFeature();
const drawFeature = this.editor.getDrawFeature();
const currentFeatures = [editFeature, drawFeature].filter((f) => !!f);
const nb = nbFeatures || 1;

const cacheDist = {};
Expand All @@ -271,7 +272,7 @@ class CadControl extends Control {
let features = this.source
.getFeatures()
.filter(this.filter)
.filter((f) => ![editFeature, drawFeature].includes(f))
.filter((f) => !currentFeatures.includes(f))
.sort(sortByDistance)
.slice(0, nb);

Expand All @@ -282,7 +283,7 @@ class CadControl extends Control {

// When using showSnapLines, return all features but edit/draw features are
// cloned to remove the node at the mouse position.
[editFeature, drawFeature].filter(this.filter).forEach((feature) => {
currentFeatures.filter(this.filter).forEach((feature) => {
const geom = feature.getGeometry();

if (!(geom instanceof Circle) && !(geom instanceof Point)) {
Expand Down
2 changes: 1 addition & 1 deletion src/control/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DrawControl extends Control {
});

this.drawInteraction.on('drawend', () => {
this.editor.setDrawFeature(null);
this.editor.setDrawFeature();
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/control/modify.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class ModifyControl extends Control {
});

this.moveInteraction.on('moveend', () => {
this.editor.setEditFeature(null);
this.editor.setEditFeature();
this.isMoving = false;
});
this.moveInteraction.setActive(false);
Expand Down Expand Up @@ -199,7 +199,7 @@ class ModifyControl extends Control {
});

this.modifyInteraction.on('modifyend', () => {
this.editor.setEditFeature(null);
this.editor.setEditFeature();
this.isModifying = false;
});
this.modifyInteraction.setActive(false);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3836,10 +3836,10 @@ object.values@^1.1.7:
define-properties "^1.2.1"
es-object-atoms "^1.0.0"

ol@9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/ol/-/ol-9.0.0.tgz#449207b0da5c31f905a030fac141e04935a126a0"
integrity sha512-+nYHZYbHrRUTDJ8ryxXPdDoAiaT6Zea02cocmGqsJXs4Oac1fYC9EbTIU2Y7803QcmG3u2MR88RxbksBvK+ZfQ==
ol@8:
version "8.2.0"
resolved "https://registry.yarnpkg.com/ol/-/ol-8.2.0.tgz#145153eab0ea3b5d04f51f46d6c69c224cccd5c3"
integrity sha512-/m1ddd7Jsp4Kbg+l7+ozR5aKHAZNQOBAoNZ5pM9Jvh4Etkf0WGkXr9qXd7PnhmwiC1Hnc2Toz9XjCzBBvexfXw==
dependencies:
color-rgba "^3.0.0"
color-space "^2.0.1"
Expand Down

0 comments on commit 5b59c54

Please sign in to comment.