Merge pull request #11821 from MoonE/draw-finish-condition

Call the finishCondition when drawing points / circles
This commit is contained in:
MoonE
2020-12-11 20:51:12 +01:00
committed by GitHub

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) {
this.startDrawing_(event.coordinate); case !this.finishCoordinate_:
if (this.mode_ === Mode.POINT) { this.startDrawing_(event.coordinate);
if (this.mode_ !== Mode.POINT) {
break;
}
// eslint-disable-next-line no-fallthrough
case this.freehand_ ||
(this.atFinish_(event.pixel) && this.finishCondition_(event)):
this.finishDrawing(); this.finishDrawing();
} break;
} else if (this.freehand_) { case !this.freehand_:
this.finishDrawing(); this.addToDrawing_(event.coordinate);
} else if (this.atFinish_(event.pixel)) { break;
if (this.finishCondition_(event)) { default:
this.finishDrawing(); break;
}
} else {
this.addToDrawing_(event.coordinate);
} }
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_);