Call the finishCondition when drawing points / circles

This commit is contained in:
Maximilian Krög
2020-12-11 00:29:30 +01:00
parent 6c6b559ce4
commit bd4622940e
+17 -10
View File
@@ -625,19 +625,22 @@ class Draw extends PointerInteraction {
this.handlePointerMove_(event); this.handlePointerMove_(event);
if (this.shouldHandle_) { if (this.shouldHandle_) {
if (!this.finishCoordinate_) { switch (true) {
case !this.finishCoordinate_:
this.startDrawing_(event.coordinate); this.startDrawing_(event.coordinate);
if (this.mode_ === Mode.POINT) { if (this.mode_ !== Mode.POINT) {
this.finishDrawing(); break;
} }
} else if (this.freehand_) { // eslint-disable-next-line no-fallthrough
case this.freehand_ ||
(this.atFinish_(event.pixel) && this.finishCondition_(event)):
this.finishDrawing(); this.finishDrawing();
} else if (this.atFinish_(event.pixel)) { break;
if (this.finishCondition_(event)) { case !this.freehand_:
this.finishDrawing();
}
} else {
this.addToDrawing_(event.coordinate); this.addToDrawing_(event.coordinate);
break;
default:
break;
} }
pass = false; pass = false;
} else if (this.freehand_) { } else if (this.freehand_) {
@@ -695,7 +698,11 @@ class Draw extends PointerInteraction {
let potentiallyDone = false; let potentiallyDone = false;
let potentiallyFinishCoordinates = [this.finishCoordinate_]; let potentiallyFinishCoordinates = [this.finishCoordinate_];
const mode = this.mode_; const mode = this.mode_;
if (mode === Mode.LINE_STRING || mode === Mode.CIRCLE) { if (mode === Mode.POINT) {
at = true;
} else if (mode === Mode.CIRCLE) {
at = this.sketchCoords_.length === 2;
} else if (mode === Mode.LINE_STRING) {
potentiallyDone = this.sketchCoords_.length > this.minPoints_; potentiallyDone = this.sketchCoords_.length > this.minPoints_;
} else if (mode === Mode.POLYGON) { } else if (mode === Mode.POLYGON) {
const sketchCoords = /** @type {PolyCoordType} */ (this.sketchCoords_); const sketchCoords = /** @type {PolyCoordType} */ (this.sketchCoords_);