Lint removal
This commit is contained in:
@@ -7,36 +7,36 @@
|
||||
* @constructor
|
||||
*/
|
||||
class EventSource {
|
||||
constructor(dispatcher, mapping) {
|
||||
/**
|
||||
constructor(dispatcher, mapping) {
|
||||
/**
|
||||
* @type {module:ol/pointer/PointerEventHandler}
|
||||
*/
|
||||
this.dispatcher = dispatcher;
|
||||
this.dispatcher = dispatcher;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @const
|
||||
* @type {!Object.<string, function(Event)>}
|
||||
*/
|
||||
this.mapping_ = mapping;
|
||||
}
|
||||
this.mapping_ = mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* List of events supported by this source.
|
||||
* @return {Array.<string>} Event names
|
||||
*/
|
||||
getEvents() {
|
||||
return Object.keys(this.mapping_);
|
||||
}
|
||||
getEvents() {
|
||||
return Object.keys(this.mapping_);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns the handler that should handle a given event type.
|
||||
* @param {string} eventType The event type.
|
||||
* @return {function(Event)} Handler
|
||||
*/
|
||||
getHandlerForEvent(eventType) {
|
||||
return this.mapping_[eventType];
|
||||
}
|
||||
getHandlerForEvent(eventType) {
|
||||
return this.mapping_[eventType];
|
||||
}
|
||||
}
|
||||
|
||||
export default EventSource;
|
||||
|
||||
@@ -34,6 +34,27 @@
|
||||
import {inherits} from '../util.js';
|
||||
import EventSource from '../pointer/EventSource.js';
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
export const POINTER_ID = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
export const POINTER_TYPE = 'mouse';
|
||||
|
||||
|
||||
/**
|
||||
* Radius around touchend that swallows mouse events.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
const DEDUP_DIST = 25;
|
||||
|
||||
|
||||
/**
|
||||
* @param {module:ol/pointer/PointerEventHandler} dispatcher Event handler.
|
||||
* @constructor
|
||||
@@ -195,26 +216,6 @@ class MouseSource {
|
||||
inherits(MouseSource, EventSource);
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
export const POINTER_ID = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
export const POINTER_TYPE = 'mouse';
|
||||
|
||||
|
||||
/**
|
||||
* Radius around touchend that swallows mouse events.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
const DEDUP_DIST = 25;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a copy of the original event that will be used
|
||||
* for the fake pointer event.
|
||||
|
||||
@@ -34,143 +34,6 @@
|
||||
import {inherits} from '../util.js';
|
||||
import EventSource from '../pointer/EventSource.js';
|
||||
|
||||
/**
|
||||
* @param {module:ol/pointer/PointerEventHandler} dispatcher Event handler.
|
||||
* @constructor
|
||||
* @extends {module:ol/pointer/EventSource}
|
||||
*/
|
||||
class MsSource {
|
||||
constructor(dispatcher) {
|
||||
const mapping = {
|
||||
'MSPointerDown': this.msPointerDown,
|
||||
'MSPointerMove': this.msPointerMove,
|
||||
'MSPointerUp': this.msPointerUp,
|
||||
'MSPointerOut': this.msPointerOut,
|
||||
'MSPointerOver': this.msPointerOver,
|
||||
'MSPointerCancel': this.msPointerCancel,
|
||||
'MSGotPointerCapture': this.msGotPointerCapture,
|
||||
'MSLostPointerCapture': this.msLostPointerCapture
|
||||
};
|
||||
EventSource.call(this, dispatcher, mapping);
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {!Object.<string, MSPointerEvent|Object>}
|
||||
*/
|
||||
this.pointerMap = dispatcher.pointerMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the original event that will be used
|
||||
* for the fake pointer event.
|
||||
*
|
||||
* @private
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
* @return {Object} The copied event.
|
||||
*/
|
||||
prepareEvent_(inEvent) {
|
||||
let e = inEvent;
|
||||
if (typeof inEvent.pointerType === 'number') {
|
||||
e = this.dispatcher.cloneEvent(inEvent, inEvent);
|
||||
e.pointerType = POINTER_TYPES[inEvent.pointerType];
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this pointer from the list of active pointers.
|
||||
* @param {number} pointerId Pointer identifier.
|
||||
*/
|
||||
cleanup(pointerId) {
|
||||
delete this.pointerMap[pointerId.toString()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerDown`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerDown(inEvent) {
|
||||
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.down(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerMove`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerMove(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.move(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerUp`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerUp(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.up(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerOut`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerOut(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.leaveOut(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerOver`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerOver(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.enterOver(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerCancel`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerCancel(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.cancel(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msLostPointerCapture`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msLostPointerCapture(inEvent) {
|
||||
const e = this.dispatcher.makeEvent('lostpointercapture', inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msGotPointerCapture`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msGotPointerCapture(inEvent) {
|
||||
const e = this.dispatcher.makeEvent('gotpointercapture', inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(MsSource, EventSource);
|
||||
|
||||
/**
|
||||
* @const
|
||||
@@ -185,4 +48,142 @@ const POINTER_TYPES = [
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param {module:ol/pointer/PointerEventHandler} dispatcher Event handler.
|
||||
* @constructor
|
||||
* @extends {module:ol/pointer/EventSource}
|
||||
*/
|
||||
class MsSource {
|
||||
constructor(dispatcher) {
|
||||
const mapping = {
|
||||
'MSPointerDown': this.msPointerDown,
|
||||
'MSPointerMove': this.msPointerMove,
|
||||
'MSPointerUp': this.msPointerUp,
|
||||
'MSPointerOut': this.msPointerOut,
|
||||
'MSPointerOver': this.msPointerOver,
|
||||
'MSPointerCancel': this.msPointerCancel,
|
||||
'MSGotPointerCapture': this.msGotPointerCapture,
|
||||
'MSLostPointerCapture': this.msLostPointerCapture
|
||||
};
|
||||
EventSource.call(this, dispatcher, mapping);
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {!Object.<string, MSPointerEvent|Object>}
|
||||
*/
|
||||
this.pointerMap = dispatcher.pointerMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the original event that will be used
|
||||
* for the fake pointer event.
|
||||
*
|
||||
* @private
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
* @return {Object} The copied event.
|
||||
*/
|
||||
prepareEvent_(inEvent) {
|
||||
let e = inEvent;
|
||||
if (typeof inEvent.pointerType === 'number') {
|
||||
e = this.dispatcher.cloneEvent(inEvent, inEvent);
|
||||
e.pointerType = POINTER_TYPES[inEvent.pointerType];
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this pointer from the list of active pointers.
|
||||
* @param {number} pointerId Pointer identifier.
|
||||
*/
|
||||
cleanup(pointerId) {
|
||||
delete this.pointerMap[pointerId.toString()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerDown`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerDown(inEvent) {
|
||||
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.down(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerMove`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerMove(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.move(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerUp`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerUp(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.up(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerOut`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerOut(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.leaveOut(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerOver`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerOver(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.enterOver(e, inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msPointerCancel`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msPointerCancel(inEvent) {
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.cancel(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msLostPointerCapture`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msLostPointerCapture(inEvent) {
|
||||
const e = this.dispatcher.makeEvent('lostpointercapture', inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for `msGotPointerCapture`.
|
||||
*
|
||||
* @param {MSPointerEvent} inEvent The in event.
|
||||
*/
|
||||
msGotPointerCapture(inEvent) {
|
||||
const e = this.dispatcher.makeEvent('gotpointercapture', inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(MsSource, EventSource);
|
||||
|
||||
export default MsSource;
|
||||
|
||||
@@ -40,91 +40,91 @@ import EventSource from '../pointer/EventSource.js';
|
||||
* @extends {module:ol/pointer/EventSource}
|
||||
*/
|
||||
class NativeSource {
|
||||
constructor(dispatcher) {
|
||||
const mapping = {
|
||||
'pointerdown': this.pointerDown,
|
||||
'pointermove': this.pointerMove,
|
||||
'pointerup': this.pointerUp,
|
||||
'pointerout': this.pointerOut,
|
||||
'pointerover': this.pointerOver,
|
||||
'pointercancel': this.pointerCancel,
|
||||
'gotpointercapture': this.gotPointerCapture,
|
||||
'lostpointercapture': this.lostPointerCapture
|
||||
};
|
||||
EventSource.call(this, dispatcher, mapping);
|
||||
}
|
||||
constructor(dispatcher) {
|
||||
const mapping = {
|
||||
'pointerdown': this.pointerDown,
|
||||
'pointermove': this.pointerMove,
|
||||
'pointerup': this.pointerUp,
|
||||
'pointerout': this.pointerOut,
|
||||
'pointerover': this.pointerOver,
|
||||
'pointercancel': this.pointerCancel,
|
||||
'gotpointercapture': this.gotPointerCapture,
|
||||
'lostpointercapture': this.lostPointerCapture
|
||||
};
|
||||
EventSource.call(this, dispatcher, mapping);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointerdown`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerDown(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerDown(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointermove`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerMove(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerMove(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointerup`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerUp(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerUp(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointerout`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerOut(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerOut(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointerover`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerOver(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerOver(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `pointercancel`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
pointerCancel(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
pointerCancel(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `lostpointercapture`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
lostPointerCapture(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
lostPointerCapture(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Handler for `gotpointercapture`.
|
||||
*
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
gotPointerCapture(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
gotPointerCapture(inEvent) {
|
||||
this.dispatcher.fireNativeEvent(inEvent);
|
||||
}
|
||||
}
|
||||
|
||||
inherits(NativeSource, EventSource);
|
||||
|
||||
@@ -34,6 +34,14 @@
|
||||
import {inherits} from '../util.js';
|
||||
import Event from '../events/Event.js';
|
||||
|
||||
|
||||
/**
|
||||
* Is the `buttons` property supported?
|
||||
* @type {boolean}
|
||||
*/
|
||||
let HAS_BUTTONS = false;
|
||||
|
||||
|
||||
/**
|
||||
* A class for pointer events.
|
||||
*
|
||||
@@ -48,221 +56,214 @@ import Event from '../events/Event.js';
|
||||
* initial event properties.
|
||||
*/
|
||||
class PointerEvent {
|
||||
constructor(type, originalEvent, opt_eventDict) {
|
||||
Event.call(this, type);
|
||||
constructor(type, originalEvent, opt_eventDict) {
|
||||
Event.call(this, type);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @const
|
||||
* @type {Event}
|
||||
*/
|
||||
this.originalEvent = originalEvent;
|
||||
this.originalEvent = originalEvent;
|
||||
|
||||
const eventDict = opt_eventDict ? opt_eventDict : {};
|
||||
const eventDict = opt_eventDict ? opt_eventDict : {};
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.buttons = this.getButtons_(eventDict);
|
||||
this.buttons = this.getButtons_(eventDict);
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.pressure = this.getPressure_(eventDict, this.buttons);
|
||||
this.pressure = this.getPressure_(eventDict, this.buttons);
|
||||
|
||||
// MouseEvent related properties
|
||||
// MouseEvent related properties
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.bubbles = 'bubbles' in eventDict ? eventDict['bubbles'] : false;
|
||||
this.bubbles = 'bubbles' in eventDict ? eventDict['bubbles'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.cancelable = 'cancelable' in eventDict ? eventDict['cancelable'] : false;
|
||||
this.cancelable = 'cancelable' in eventDict ? eventDict['cancelable'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {Object}
|
||||
*/
|
||||
this.view = 'view' in eventDict ? eventDict['view'] : null;
|
||||
this.view = 'view' in eventDict ? eventDict['view'] : null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.detail = 'detail' in eventDict ? eventDict['detail'] : null;
|
||||
this.detail = 'detail' in eventDict ? eventDict['detail'] : null;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.screenX = 'screenX' in eventDict ? eventDict['screenX'] : 0;
|
||||
this.screenX = 'screenX' in eventDict ? eventDict['screenX'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.screenY = 'screenY' in eventDict ? eventDict['screenY'] : 0;
|
||||
this.screenY = 'screenY' in eventDict ? eventDict['screenY'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.clientX = 'clientX' in eventDict ? eventDict['clientX'] : 0;
|
||||
this.clientX = 'clientX' in eventDict ? eventDict['clientX'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.clientY = 'clientY' in eventDict ? eventDict['clientY'] : 0;
|
||||
this.clientY = 'clientY' in eventDict ? eventDict['clientY'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.ctrlKey = 'ctrlKey' in eventDict ? eventDict['ctrlKey'] : false;
|
||||
this.ctrlKey = 'ctrlKey' in eventDict ? eventDict['ctrlKey'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.altKey = 'altKey' in eventDict ? eventDict['altKey'] : false;
|
||||
this.altKey = 'altKey' in eventDict ? eventDict['altKey'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.shiftKey = 'shiftKey' in eventDict ? eventDict['shiftKey'] : false;
|
||||
this.shiftKey = 'shiftKey' in eventDict ? eventDict['shiftKey'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.metaKey = 'metaKey' in eventDict ? eventDict['metaKey'] : false;
|
||||
this.metaKey = 'metaKey' in eventDict ? eventDict['metaKey'] : false;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.button = 'button' in eventDict ? eventDict['button'] : 0;
|
||||
this.button = 'button' in eventDict ? eventDict['button'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {Node}
|
||||
*/
|
||||
this.relatedTarget = 'relatedTarget' in eventDict ?
|
||||
eventDict['relatedTarget'] : null;
|
||||
this.relatedTarget = 'relatedTarget' in eventDict ?
|
||||
eventDict['relatedTarget'] : null;
|
||||
|
||||
// PointerEvent related properties
|
||||
// PointerEvent related properties
|
||||
|
||||
/**
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
this.pointerId = 'pointerId' in eventDict ? eventDict['pointerId'] : 0;
|
||||
this.pointerId = 'pointerId' in eventDict ? eventDict['pointerId'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.width = 'width' in eventDict ? eventDict['width'] : 0;
|
||||
this.width = 'width' in eventDict ? eventDict['width'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.height = 'height' in eventDict ? eventDict['height'] : 0;
|
||||
this.height = 'height' in eventDict ? eventDict['height'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.tiltX = 'tiltX' in eventDict ? eventDict['tiltX'] : 0;
|
||||
this.tiltX = 'tiltX' in eventDict ? eventDict['tiltX'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.tiltY = 'tiltY' in eventDict ? eventDict['tiltY'] : 0;
|
||||
this.tiltY = 'tiltY' in eventDict ? eventDict['tiltY'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
this.pointerType = 'pointerType' in eventDict ? eventDict['pointerType'] : '';
|
||||
this.pointerType = 'pointerType' in eventDict ? eventDict['pointerType'] : '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.hwTimestamp = 'hwTimestamp' in eventDict ? eventDict['hwTimestamp'] : 0;
|
||||
this.hwTimestamp = 'hwTimestamp' in eventDict ? eventDict['hwTimestamp'] : 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isPrimary = 'isPrimary' in eventDict ? eventDict['isPrimary'] : false;
|
||||
this.isPrimary = 'isPrimary' in eventDict ? eventDict['isPrimary'] : false;
|
||||
|
||||
// keep the semantics of preventDefault
|
||||
if (originalEvent.preventDefault) {
|
||||
this.preventDefault = function() {
|
||||
originalEvent.preventDefault();
|
||||
};
|
||||
}
|
||||
}
|
||||
// keep the semantics of preventDefault
|
||||
if (originalEvent.preventDefault) {
|
||||
this.preventDefault = function() {
|
||||
originalEvent.preventDefault();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @param {Object.<string, ?>} eventDict The event dictionary.
|
||||
* @return {number} Button indicator.
|
||||
*/
|
||||
getButtons_(eventDict) {
|
||||
// According to the w3c spec,
|
||||
// http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-button
|
||||
// MouseEvent.button == 0 can mean either no mouse button depressed, or the
|
||||
// left mouse button depressed.
|
||||
//
|
||||
// As of now, the only way to distinguish between the two states of
|
||||
// MouseEvent.button is by using the deprecated MouseEvent.which property, as
|
||||
// this maps mouse buttons to positive integers > 0, and uses 0 to mean that
|
||||
// no mouse button is held.
|
||||
//
|
||||
// MouseEvent.which is derived from MouseEvent.button at MouseEvent creation,
|
||||
// but initMouseEvent does not expose an argument with which to set
|
||||
// MouseEvent.which. Calling initMouseEvent with a buttonArg of 0 will set
|
||||
// MouseEvent.button == 0 and MouseEvent.which == 1, breaking the expectations
|
||||
// of app developers.
|
||||
//
|
||||
// The only way to propagate the correct state of MouseEvent.which and
|
||||
// MouseEvent.button to a new MouseEvent.button == 0 and MouseEvent.which == 0
|
||||
// is to call initMouseEvent with a buttonArg value of -1.
|
||||
//
|
||||
// This is fixed with DOM Level 4's use of buttons
|
||||
let buttons;
|
||||
if (eventDict.buttons || HAS_BUTTONS) {
|
||||
buttons = eventDict.buttons;
|
||||
} else {
|
||||
switch (eventDict.which) {
|
||||
case 1: buttons = 1; break;
|
||||
case 2: buttons = 4; break;
|
||||
case 3: buttons = 2; break;
|
||||
default: buttons = 0;
|
||||
}
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
getButtons_(eventDict) {
|
||||
// According to the w3c spec,
|
||||
// http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-button
|
||||
// MouseEvent.button == 0 can mean either no mouse button depressed, or the
|
||||
// left mouse button depressed.
|
||||
//
|
||||
// As of now, the only way to distinguish between the two states of
|
||||
// MouseEvent.button is by using the deprecated MouseEvent.which property, as
|
||||
// this maps mouse buttons to positive integers > 0, and uses 0 to mean that
|
||||
// no mouse button is held.
|
||||
//
|
||||
// MouseEvent.which is derived from MouseEvent.button at MouseEvent creation,
|
||||
// but initMouseEvent does not expose an argument with which to set
|
||||
// MouseEvent.which. Calling initMouseEvent with a buttonArg of 0 will set
|
||||
// MouseEvent.button == 0 and MouseEvent.which == 1, breaking the expectations
|
||||
// of app developers.
|
||||
//
|
||||
// The only way to propagate the correct state of MouseEvent.which and
|
||||
// MouseEvent.button to a new MouseEvent.button == 0 and MouseEvent.which == 0
|
||||
// is to call initMouseEvent with a buttonArg value of -1.
|
||||
//
|
||||
// This is fixed with DOM Level 4's use of buttons
|
||||
let buttons;
|
||||
if (eventDict.buttons || HAS_BUTTONS) {
|
||||
buttons = eventDict.buttons;
|
||||
} else {
|
||||
switch (eventDict.which) {
|
||||
case 1: buttons = 1; break;
|
||||
case 2: buttons = 4; break;
|
||||
case 3: buttons = 2; break;
|
||||
default: buttons = 0;
|
||||
}
|
||||
}
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @private
|
||||
* @param {Object.<string, ?>} eventDict The event dictionary.
|
||||
* @param {number} buttons Button indicator.
|
||||
* @return {number} The pressure.
|
||||
*/
|
||||
getPressure_(eventDict, buttons) {
|
||||
// Spec requires that pointers without pressure specified use 0.5 for down
|
||||
// state and 0 for up state.
|
||||
let pressure = 0;
|
||||
if (eventDict.pressure) {
|
||||
pressure = eventDict.pressure;
|
||||
} else {
|
||||
pressure = buttons ? 0.5 : 0;
|
||||
}
|
||||
return pressure;
|
||||
}
|
||||
getPressure_(eventDict, buttons) {
|
||||
// Spec requires that pointers without pressure specified use 0.5 for down
|
||||
// state and 0 for up state.
|
||||
let pressure = 0;
|
||||
if (eventDict.pressure) {
|
||||
pressure = eventDict.pressure;
|
||||
} else {
|
||||
pressure = buttons ? 0.5 : 0;
|
||||
}
|
||||
return pressure;
|
||||
}
|
||||
}
|
||||
|
||||
inherits(PointerEvent, Event);
|
||||
|
||||
|
||||
/**
|
||||
* Is the `buttons` property supported?
|
||||
* @type {boolean}
|
||||
*/
|
||||
let HAS_BUTTONS = false;
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the `buttons` property is supported.
|
||||
*/
|
||||
@@ -274,4 +275,5 @@ let HAS_BUTTONS = false;
|
||||
// pass
|
||||
}
|
||||
})();
|
||||
|
||||
export default PointerEvent;
|
||||
|
||||
@@ -42,6 +42,47 @@ import NativeSource from '../pointer/NativeSource.js';
|
||||
import PointerEvent from '../pointer/PointerEvent.js';
|
||||
import TouchSource from '../pointer/TouchSource.js';
|
||||
|
||||
|
||||
/**
|
||||
* Properties to copy when cloning an event, with default values.
|
||||
* @type {Array.<Array>}
|
||||
*/
|
||||
const CLONE_PROPS = [
|
||||
// MouseEvent
|
||||
['bubbles', false],
|
||||
['cancelable', false],
|
||||
['view', null],
|
||||
['detail', null],
|
||||
['screenX', 0],
|
||||
['screenY', 0],
|
||||
['clientX', 0],
|
||||
['clientY', 0],
|
||||
['ctrlKey', false],
|
||||
['altKey', false],
|
||||
['shiftKey', false],
|
||||
['metaKey', false],
|
||||
['button', 0],
|
||||
['relatedTarget', null],
|
||||
// DOM Level 3
|
||||
['buttons', 0],
|
||||
// PointerEvent
|
||||
['pointerId', 0],
|
||||
['width', 0],
|
||||
['height', 0],
|
||||
['pressure', 0],
|
||||
['tiltX', 0],
|
||||
['tiltY', 0],
|
||||
['pointerType', ''],
|
||||
['hwTimestamp', 0],
|
||||
['isPrimary', false],
|
||||
// event instance
|
||||
['type', ''],
|
||||
['target', null],
|
||||
['currentTarget', null],
|
||||
['which', 0]
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {module:ol/events/EventTarget}
|
||||
@@ -377,44 +418,4 @@ class PointerEventHandler {
|
||||
|
||||
inherits(PointerEventHandler, EventTarget);
|
||||
|
||||
/**
|
||||
* Properties to copy when cloning an event, with default values.
|
||||
* @type {Array.<Array>}
|
||||
*/
|
||||
const CLONE_PROPS = [
|
||||
// MouseEvent
|
||||
['bubbles', false],
|
||||
['cancelable', false],
|
||||
['view', null],
|
||||
['detail', null],
|
||||
['screenX', 0],
|
||||
['screenY', 0],
|
||||
['clientX', 0],
|
||||
['clientY', 0],
|
||||
['ctrlKey', false],
|
||||
['altKey', false],
|
||||
['shiftKey', false],
|
||||
['metaKey', false],
|
||||
['button', 0],
|
||||
['relatedTarget', null],
|
||||
// DOM Level 3
|
||||
['buttons', 0],
|
||||
// PointerEvent
|
||||
['pointerId', 0],
|
||||
['width', 0],
|
||||
['height', 0],
|
||||
['pressure', 0],
|
||||
['tiltX', 0],
|
||||
['tiltY', 0],
|
||||
['pointerType', ''],
|
||||
['hwTimestamp', 0],
|
||||
['isPrimary', false],
|
||||
// event instance
|
||||
['type', ''],
|
||||
['target', null],
|
||||
['currentTarget', null],
|
||||
['which', 0]
|
||||
];
|
||||
|
||||
|
||||
export default PointerEventHandler;
|
||||
|
||||
@@ -37,6 +37,18 @@ import EventSource from '../pointer/EventSource.js';
|
||||
import {POINTER_ID} from '../pointer/MouseSource.js';
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
const CLICK_COUNT_TIMEOUT = 200;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
const POINTER_TYPE = 'touch';
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {module:ol/pointer/PointerEventHandler} dispatcher The event handler.
|
||||
@@ -411,15 +423,4 @@ class TouchSource {
|
||||
inherits(TouchSource, EventSource);
|
||||
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
const CLICK_COUNT_TIMEOUT = 200;
|
||||
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
const POINTER_TYPE = 'touch';
|
||||
|
||||
export default TouchSource;
|
||||
|
||||
Reference in New Issue
Block a user