add stylus and touch mode to drawing a shape

This commit is contained in:
Huy Nguyen
2019-02-20 13:55:22 +07:00
parent 7c1e16abc3
commit 0c889da99c
2 changed files with 14 additions and 2 deletions

View File

@@ -230,6 +230,19 @@ export const mouseOnly = function(mapBrowserEvent) {
return pointerEvent.pointerType == 'mouse';
};
export const touchOnly = (mapBrowserEvent) => {
const pointerEvt = /** @type {import("../MapBrowserPointerEvent").default} */ (mapBrowserEvent).pointerEvent;
assert(pointerEvt !== undefined, 56); // mapBrowserEvent must originate from a pointer event
// see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType
return pointerEvt.pointerType === 'touch';
};
export const penOnly = (mapBrowserEvent) => {
const pointerEvt = /** @type {import("../MapBrowserPointerEvent").default} */ (mapBrowserEvent).pointerEvent;
assert(pointerEvt !== undefined, 56); // mapBrowserEvent must originate from a pointer event
// see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType
return pointerEvt.pointerType === 'pen';
};
/**
* Return `true` if the event originates from a primary pointer in

View File

@@ -528,7 +528,7 @@ class Draw extends PointerInteraction {
handleDownEvent(event) {
this.shouldHandle_ = !this.freehand_;
if (this.freehand_) {
if (this.freehand_ && ((this.condition_ && this.condition_(event)) || true)) {
this.downPx_ = event.pixel;
if (!this.finishCoordinate_) {
this.startDrawing_(event);
@@ -548,7 +548,6 @@ class Draw extends PointerInteraction {
}
}
/**
* @inheritDoc
*/