From 658a2b317e184a7a209693e7339adb97305c47b4 Mon Sep 17 00:00:00 2001 From: drnextgis Date: Fri, 18 Mar 2016 11:10:27 +0600 Subject: [PATCH] correct way to determine freehand mode is enabled --- src/ol/interaction/drawinteraction.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ol/interaction/drawinteraction.js b/src/ol/interaction/drawinteraction.js index 79eab3e9553..43e71eecb31 100644 --- a/src/ol/interaction/drawinteraction.js +++ b/src/ol/interaction/drawinteraction.js @@ -337,6 +337,11 @@ ol.interaction.Draw.prototype.setMap = function(map) { * @api */ ol.interaction.Draw.handleEvent = function(mapBrowserEvent) { + if ((this.mode_ === ol.interaction.DrawMode.LINE_STRING || + this.mode_ === ol.interaction.DrawMode.POLYGON) && + this.freehandCondition_(mapBrowserEvent)) { + this.freehand_ = true; + } var pass = !this.freehand_; if (this.freehand_ && mapBrowserEvent.type === ol.MapBrowserEvent.EventType.POINTERDRAG) { @@ -362,11 +367,8 @@ ol.interaction.Draw.handleDownEvent_ = function(event) { if (this.condition_(event)) { this.downPx_ = event.pixel; return true; - } else if ((this.mode_ === ol.interaction.DrawMode.LINE_STRING || - this.mode_ === ol.interaction.DrawMode.POLYGON) && - this.freehandCondition_(event)) { + } else if (this.freehand_) { this.downPx_ = event.pixel; - this.freehand_ = true; if (!this.finishCoordinate_) { this.startDrawing_(event); }