From 2df22af3cace81eca3b91c8da48ce490deafed36 Mon Sep 17 00:00:00 2001 From: Greg Gianforcaro Date: Tue, 19 Nov 2019 22:46:04 -0500 Subject: [PATCH 1/2] Update DragBox to use only condition for filtering - Remove mouseOnly and mouseActionButton hardcoded filters - Default condition to mouseActionButton --- src/ol/interaction/DragBox.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/ol/interaction/DragBox.js b/src/ol/interaction/DragBox.js index 14265ed365..dc8f7fca3e 100644 --- a/src/ol/interaction/DragBox.js +++ b/src/ol/interaction/DragBox.js @@ -3,7 +3,7 @@ */ // FIXME draw drag box import Event from '../events/Event.js'; -import {always, mouseOnly, mouseActionButton} from '../events/condition.js'; +import {mouseActionButton} from '../events/condition.js'; import {VOID} from '../functions.js'; import PointerInteraction from './Pointer.js'; import RenderBox from '../render/Box.js'; @@ -148,7 +148,7 @@ class DragBox extends PointerInteraction { * @private * @type {import("../events/condition.js").Condition} */ - this.condition_ = options.condition ? options.condition : always; + this.condition_ = options.condition ? options.condition : mouseActionButton; /** * @private @@ -186,10 +186,6 @@ class DragBox extends PointerInteraction { * @inheritDoc */ handleDragEvent(mapBrowserEvent) { - if (!mouseOnly(mapBrowserEvent)) { - return; - } - this.box_.setPixels(this.startPixel_, mapBrowserEvent.pixel); this.dispatchEvent(new DragBoxEvent(DragBoxEventType.BOXDRAG, @@ -200,10 +196,6 @@ class DragBox extends PointerInteraction { * @inheritDoc */ handleUpEvent(mapBrowserEvent) { - if (!mouseOnly(mapBrowserEvent)) { - return true; - } - this.box_.setMap(null); if (this.boxEndCondition_(mapBrowserEvent, this.startPixel_, mapBrowserEvent.pixel)) { @@ -218,12 +210,7 @@ class DragBox extends PointerInteraction { * @inheritDoc */ handleDownEvent(mapBrowserEvent) { - if (!mouseOnly(mapBrowserEvent)) { - return false; - } - - if (mouseActionButton(mapBrowserEvent) && - this.condition_(mapBrowserEvent)) { + if (this.condition_(mapBrowserEvent)) { this.startPixel_ = mapBrowserEvent.pixel; this.box_.setMap(mapBrowserEvent.map); this.box_.setPixels(this.startPixel_, this.startPixel_); From d99c77b99206ce38e22ff00c289f6a15144b276f Mon Sep 17 00:00:00 2001 From: Greg Gianforcaro Date: Fri, 22 Nov 2019 16:35:31 -0500 Subject: [PATCH 2/2] Update DragBox jsdoc - update the typedef to change the condition default value to {@link ol/events/condition~mouseActionButton} - remove 'This interaction is only supported for mouse devices' comment --- src/ol/interaction/DragBox.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ol/interaction/DragBox.js b/src/ol/interaction/DragBox.js index dc8f7fca3e..28ae6ecbe0 100644 --- a/src/ol/interaction/DragBox.js +++ b/src/ol/interaction/DragBox.js @@ -22,7 +22,7 @@ import RenderBox from '../render/Box.js'; * @property {string} [className='ol-dragbox'] CSS class name for styling the box. * @property {import("../events/condition.js").Condition} [condition] A function that takes an {@link module:ol/MapBrowserEvent~MapBrowserEvent} and returns a boolean * to indicate whether that event should be handled. - * Default is {@link ol/events/condition~always}. + * Default is {@link ol/events/condition~mouseActionButton}. * @property {number} [minArea=64] The minimum area of the box in pixel, this value is used by the default * `boxEndCondition` function. * @property {EndCondition} [boxEndCondition] A function that takes a {@link module:ol/MapBrowserEvent~MapBrowserEvent} and two @@ -104,8 +104,6 @@ class DragBoxEvent extends Event { * (see {@link module:ol/interaction/DragZoom~DragZoom} and * {@link module:ol/interaction/DragRotateAndZoom}). * - * This interaction is only supported for mouse devices. - * * @fires DragBoxEvent * @api */