Merge pull request #11780 from M393/dragbox-add-cancel-event
Add a cancel event to the DragBox interaction
This commit is contained in:
@@ -53,6 +53,13 @@ const DragBoxEventType = {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
BOXEND: 'boxend',
|
BOXEND: 'boxend',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered upon drag box canceled.
|
||||||
|
* @event DragBoxEvent#boxcancel
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
BOXCANCEL: 'boxcancel',
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,22 +199,21 @@ class DragBox extends PointerInteraction {
|
|||||||
handleUpEvent(mapBrowserEvent) {
|
handleUpEvent(mapBrowserEvent) {
|
||||||
this.box_.setMap(null);
|
this.box_.setMap(null);
|
||||||
|
|
||||||
if (
|
const completeBox = this.boxEndCondition_(
|
||||||
this.boxEndCondition_(
|
mapBrowserEvent,
|
||||||
mapBrowserEvent,
|
this.startPixel_,
|
||||||
this.startPixel_,
|
mapBrowserEvent.pixel
|
||||||
mapBrowserEvent.pixel
|
);
|
||||||
)
|
if (completeBox) {
|
||||||
) {
|
|
||||||
this.onBoxEnd(mapBrowserEvent);
|
this.onBoxEnd(mapBrowserEvent);
|
||||||
this.dispatchEvent(
|
|
||||||
new DragBoxEvent(
|
|
||||||
DragBoxEventType.BOXEND,
|
|
||||||
mapBrowserEvent.coordinate,
|
|
||||||
mapBrowserEvent
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
this.dispatchEvent(
|
||||||
|
new DragBoxEvent(
|
||||||
|
completeBox ? DragBoxEventType.BOXEND : DragBoxEventType.BOXCANCEL,
|
||||||
|
mapBrowserEvent.coordinate,
|
||||||
|
mapBrowserEvent
|
||||||
|
)
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user