remove arrow function, add JSDoc and restore original Draw

This commit is contained in:
Huy Nguyen
2019-02-20 17:23:50 +07:00
parent 0c889da99c
commit c3709ef51a
2 changed files with 18 additions and 3 deletions

View File

@@ -230,14 +230,28 @@ export const mouseOnly = function(mapBrowserEvent) {
return pointerEvent.pointerType == 'mouse';
};
export const touchOnly = (mapBrowserEvent) => {
/**
* Return `true` if the event originates from a touchable device.
*
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
* @return {boolean} True if the event originates from a touchable device.
* @api
*/
export const touchOnly = function(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) => {
/**
* Return `true` if the event originates from a digital pen.
*
* @param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
* @return {boolean} True if the event originates from a digital pen.
* @api
*/
export const penOnly = function(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

View File

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