Skip to content

Commit

Permalink
Merge pull request #1379 from swisstopo/fix/viewer-1349-geometry-edit…
Browse files Browse the repository at this point in the history
…-freeze

Fix 1349:  Geometry Edit Freeze
  • Loading branch information
vej-ananas authored Nov 15, 2024
2 parents c8d179a + 171dec1 commit 0498c0d
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions ui/src/draw/CesiumDraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class CesiumDraw extends EventTarget {
private leftPressedPixel_: Cartesian2 | undefined;
private sketchPoints_: Entity[] = [];
private isDoubleClick = false;
private singleClickTimer;
private singleClickTimer: NodeJS.Timeout | null = null;
private segmentsInfo: SegmentInfo[] = [];
type: GeometryTypes | undefined;
julianDate = new JulianDate();
Expand Down Expand Up @@ -462,11 +462,17 @@ export class CesiumDraw extends EventTarget {
this.finishDrawing();
} else if (this.type === 'line') {
if (!this.isDoubleClick) {
this.singleClickTimer = setTimeout(() => {
this.isDoubleClick = false;
const prevPoint = Cartesian3.clone(this.activePoints_[this.activePoints_.length - 1]);
this.sketchPoints_.push(this.createSketchPoint_(prevPoint));
}, 250);
if (this.singleClickTimer) {
clearTimeout(this.singleClickTimer);
this.singleClickTimer = null;
} else {
this.singleClickTimer = setTimeout(() => {
this.isDoubleClick = false;
const prevPoint = Cartesian3.clone(this.activePoints_[this.activePoints_.length - 1]);
this.sketchPoints_.push(this.createSketchPoint_(prevPoint));
this.singleClickTimer = null;
}, 250);
}
}
}
}
Expand Down Expand Up @@ -616,7 +622,9 @@ export class CesiumDraw extends EventTarget {

onDoubleClick_() {
this.isDoubleClick = true;
clearTimeout(this.singleClickTimer);
if (this.singleClickTimer) {
clearTimeout(this.singleClickTimer);
}
if (!this.activeDistances_.includes(this.activeDistance_)) {
this.activeDistances_.push(this.activeDistance_);
}
Expand Down

0 comments on commit 0498c0d

Please sign in to comment.