Merge pull request #12185 from ahocevar/prevent-default
MapBrowserEvent#preventDefault() behaves the same as with native events
This commit is contained in:
@@ -201,10 +201,10 @@ class MapBrowserEventHandler extends Target {
|
||||
// to 0).
|
||||
// See http://www.w3.org/TR/pointerevents/#button-states
|
||||
// We only fire click, singleclick, and doubleclick if nobody has called
|
||||
// event.stopPropagation() or event.preventDefault().
|
||||
// event.preventDefault().
|
||||
if (
|
||||
this.emulateClicks_ &&
|
||||
!newEvent.propagationStopped &&
|
||||
!newEvent.defaultPrevented &&
|
||||
!this.dragging_ &&
|
||||
this.isMouseActionButton_(pointerEvent)
|
||||
) {
|
||||
|
||||
@@ -22,6 +22,11 @@ class BaseEvent {
|
||||
*/
|
||||
this.propagationStopped;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.defaultPrevented;
|
||||
|
||||
/**
|
||||
* The event type.
|
||||
* @type {string}
|
||||
@@ -38,11 +43,12 @@ class BaseEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop event propagation.
|
||||
* Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events
|
||||
* will be fired.
|
||||
* @api
|
||||
*/
|
||||
preventDefault() {
|
||||
this.propagationStopped = true;
|
||||
this.defaultPrevented = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -650,7 +650,7 @@ class Draw extends PointerInteraction {
|
||||
}
|
||||
|
||||
if (!pass && this.stopClick_) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
}
|
||||
return pass;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user