Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Viglino/ol-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
Viglino committed Nov 21, 2024
2 parents eb87c07 + fa4516b commit 4ebe755
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/interaction/DrawRegular.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ var ol_interaction_DrawRegular = class olinteractionDrawRegular extends ol_inter
handleEvent_(evt) {
var dx, dy
// Event date time
this._eventTime = new Date()
this._eventTime = new Date();

switch (evt.type) {
case "pointerdown": {
if (this.conditionFn_ && !this.conditionFn_(evt))
Expand All @@ -274,16 +275,18 @@ var ol_interaction_DrawRegular = class olinteractionDrawRegular extends ol_inter
if (this._longTouch)
this.handleMoveEvent_(evt)
}.bind(this), dt)
this.lastEvent = evt.type;
break
}
case "pointerup": {
// Started and fisrt move
if (this.started_ && this.coord_) {
dx = this.downPx_[0] - evt.pixel[0]
dy = this.downPx_[1] - evt.pixel[1]

if (dx * dx + dy * dy <= this.squaredClickTolerance_) {
// The pointer has moved
if (this.lastEvent == "pointermove" || this.lastEvent == "keydown") {
if (this.lastEvent == "pointerdown" || this.lastEvent == "pointermove" || this.lastEvent == "keydown") {
this.end_(evt)
}

Expand Down Expand Up @@ -327,12 +330,13 @@ var ol_interaction_DrawRegular = class olinteractionDrawRegular extends ol_inter
break
}
default: {
this.lastEvent = evt.type
// Prevent zoom in on dblclick
if (this.started_ && evt.type === 'dblclick') {
// Prevent zoom or other event on click/singleclick/dblclick
if (this.started_ && (evt.type === 'click' || evt.type === 'singleclick' || evt.type === 'dblclick')) {
//evt.stopPropagation();
return false
}
this.lastEvent = evt.type

break
}
}
Expand Down

0 comments on commit 4ebe755

Please sign in to comment.