Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
* mapping.
|
||||
* @constructor
|
||||
*/
|
||||
var _ol_pointer_EventSource_ = function(dispatcher, mapping) {
|
||||
const _ol_pointer_EventSource_ = function(dispatcher, mapping) {
|
||||
/**
|
||||
* @type {ol.pointer.PointerEventHandler}
|
||||
*/
|
||||
|
||||
@@ -39,8 +39,8 @@ import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
|
||||
* @constructor
|
||||
* @extends {ol.pointer.EventSource}
|
||||
*/
|
||||
var _ol_pointer_MouseSource_ = function(dispatcher) {
|
||||
var mapping = {
|
||||
const _ol_pointer_MouseSource_ = function(dispatcher) {
|
||||
const mapping = {
|
||||
'mousedown': this.mousedown,
|
||||
'mousemove': this.mousemove,
|
||||
'mouseup': this.mouseup,
|
||||
@@ -113,11 +113,13 @@ _ol_pointer_MouseSource_.DEDUP_DIST = 25;
|
||||
* @return {boolean} True, if the event was generated by a touch.
|
||||
*/
|
||||
_ol_pointer_MouseSource_.prototype.isEventSimulatedFromTouch_ = function(inEvent) {
|
||||
var lts = this.lastTouches;
|
||||
var x = inEvent.clientX, y = inEvent.clientY;
|
||||
for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {
|
||||
const lts = this.lastTouches;
|
||||
const x = inEvent.clientX;
|
||||
const y = inEvent.clientY;
|
||||
for (let i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {
|
||||
// simulated mouse events will be swallowed near a primary touchend
|
||||
var dx = Math.abs(x - t[0]), dy = Math.abs(y - t[1]);
|
||||
const dx = Math.abs(x - t[0]);
|
||||
const dy = Math.abs(y - t[1]);
|
||||
if (dx <= _ol_pointer_MouseSource_.DEDUP_DIST &&
|
||||
dy <= _ol_pointer_MouseSource_.DEDUP_DIST) {
|
||||
return true;
|
||||
@@ -136,10 +138,10 @@ _ol_pointer_MouseSource_.prototype.isEventSimulatedFromTouch_ = function(inEvent
|
||||
* @return {Object} The copied event.
|
||||
*/
|
||||
_ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) {
|
||||
var e = dispatcher.cloneEvent(inEvent, inEvent);
|
||||
const e = dispatcher.cloneEvent(inEvent, inEvent);
|
||||
|
||||
// forward mouse preventDefault
|
||||
var pd = e.preventDefault;
|
||||
const pd = e.preventDefault;
|
||||
e.preventDefault = function() {
|
||||
inEvent.preventDefault();
|
||||
pd();
|
||||
@@ -165,7 +167,7 @@ _ol_pointer_MouseSource_.prototype.mousedown = function(inEvent) {
|
||||
if (_ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap) {
|
||||
this.cancel(inEvent);
|
||||
}
|
||||
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()] = inEvent;
|
||||
this.dispatcher.down(e, inEvent);
|
||||
}
|
||||
@@ -179,7 +181,7 @@ _ol_pointer_MouseSource_.prototype.mousedown = function(inEvent) {
|
||||
*/
|
||||
_ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) {
|
||||
if (!this.isEventSimulatedFromTouch_(inEvent)) {
|
||||
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
this.dispatcher.move(e, inEvent);
|
||||
}
|
||||
};
|
||||
@@ -192,10 +194,10 @@ _ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) {
|
||||
*/
|
||||
_ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) {
|
||||
if (!this.isEventSimulatedFromTouch_(inEvent)) {
|
||||
var p = this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()];
|
||||
const p = this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()];
|
||||
|
||||
if (p && p.button === inEvent.button) {
|
||||
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
this.dispatcher.up(e, inEvent);
|
||||
this.cleanupMouse();
|
||||
}
|
||||
@@ -210,7 +212,7 @@ _ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) {
|
||||
*/
|
||||
_ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) {
|
||||
if (!this.isEventSimulatedFromTouch_(inEvent)) {
|
||||
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
this.dispatcher.enterOver(e, inEvent);
|
||||
}
|
||||
};
|
||||
@@ -223,7 +225,7 @@ _ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) {
|
||||
*/
|
||||
_ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) {
|
||||
if (!this.isEventSimulatedFromTouch_(inEvent)) {
|
||||
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
this.dispatcher.leaveOut(e, inEvent);
|
||||
}
|
||||
};
|
||||
@@ -235,7 +237,7 @@ _ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_MouseSource_.prototype.cancel = function(inEvent) {
|
||||
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
|
||||
this.dispatcher.cancel(e, inEvent);
|
||||
this.cleanupMouse();
|
||||
};
|
||||
|
||||
@@ -39,8 +39,8 @@ import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
|
||||
* @constructor
|
||||
* @extends {ol.pointer.EventSource}
|
||||
*/
|
||||
var _ol_pointer_MsSource_ = function(dispatcher) {
|
||||
var mapping = {
|
||||
const _ol_pointer_MsSource_ = function(dispatcher) {
|
||||
const mapping = {
|
||||
'MSPointerDown': this.msPointerDown,
|
||||
'MSPointerMove': this.msPointerMove,
|
||||
'MSPointerUp': this.msPointerUp,
|
||||
@@ -83,7 +83,7 @@ inherits(_ol_pointer_MsSource_, _ol_pointer_EventSource_);
|
||||
* @return {Object} The copied event.
|
||||
*/
|
||||
_ol_pointer_MsSource_.prototype.prepareEvent_ = function(inEvent) {
|
||||
var e = inEvent;
|
||||
let e = inEvent;
|
||||
if (typeof inEvent.pointerType === 'number') {
|
||||
e = this.dispatcher.cloneEvent(inEvent, inEvent);
|
||||
e.pointerType = this.POINTER_TYPES[inEvent.pointerType];
|
||||
@@ -109,7 +109,7 @@ _ol_pointer_MsSource_.prototype.cleanup = function(pointerId) {
|
||||
*/
|
||||
_ol_pointer_MsSource_.prototype.msPointerDown = function(inEvent) {
|
||||
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
|
||||
var e = this.prepareEvent_(inEvent);
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.down(e, inEvent);
|
||||
};
|
||||
|
||||
@@ -120,7 +120,7 @@ _ol_pointer_MsSource_.prototype.msPointerDown = function(inEvent) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_MsSource_.prototype.msPointerMove = function(inEvent) {
|
||||
var e = this.prepareEvent_(inEvent);
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.move(e, inEvent);
|
||||
};
|
||||
|
||||
@@ -131,7 +131,7 @@ _ol_pointer_MsSource_.prototype.msPointerMove = function(inEvent) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_MsSource_.prototype.msPointerUp = function(inEvent) {
|
||||
var e = this.prepareEvent_(inEvent);
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.up(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
};
|
||||
@@ -143,7 +143,7 @@ _ol_pointer_MsSource_.prototype.msPointerUp = function(inEvent) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_MsSource_.prototype.msPointerOut = function(inEvent) {
|
||||
var e = this.prepareEvent_(inEvent);
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.leaveOut(e, inEvent);
|
||||
};
|
||||
|
||||
@@ -154,7 +154,7 @@ _ol_pointer_MsSource_.prototype.msPointerOut = function(inEvent) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_MsSource_.prototype.msPointerOver = function(inEvent) {
|
||||
var e = this.prepareEvent_(inEvent);
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.enterOver(e, inEvent);
|
||||
};
|
||||
|
||||
@@ -165,7 +165,7 @@ _ol_pointer_MsSource_.prototype.msPointerOver = function(inEvent) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_MsSource_.prototype.msPointerCancel = function(inEvent) {
|
||||
var e = this.prepareEvent_(inEvent);
|
||||
const e = this.prepareEvent_(inEvent);
|
||||
this.dispatcher.cancel(e, inEvent);
|
||||
this.cleanup(inEvent.pointerId);
|
||||
};
|
||||
@@ -177,8 +177,8 @@ _ol_pointer_MsSource_.prototype.msPointerCancel = function(inEvent) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_MsSource_.prototype.msLostPointerCapture = function(inEvent) {
|
||||
var e = this.dispatcher.makeEvent('lostpointercapture',
|
||||
inEvent, inEvent);
|
||||
const e = this.dispatcher.makeEvent('lostpointercapture',
|
||||
inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
};
|
||||
|
||||
@@ -189,8 +189,8 @@ _ol_pointer_MsSource_.prototype.msLostPointerCapture = function(inEvent) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_MsSource_.prototype.msGotPointerCapture = function(inEvent) {
|
||||
var e = this.dispatcher.makeEvent('gotpointercapture',
|
||||
inEvent, inEvent);
|
||||
const e = this.dispatcher.makeEvent('gotpointercapture',
|
||||
inEvent, inEvent);
|
||||
this.dispatcher.dispatchEvent(e);
|
||||
};
|
||||
export default _ol_pointer_MsSource_;
|
||||
|
||||
@@ -39,8 +39,8 @@ import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
|
||||
* @constructor
|
||||
* @extends {ol.pointer.EventSource}
|
||||
*/
|
||||
var _ol_pointer_NativeSource_ = function(dispatcher) {
|
||||
var mapping = {
|
||||
const _ol_pointer_NativeSource_ = function(dispatcher) {
|
||||
const mapping = {
|
||||
'pointerdown': this.pointerDown,
|
||||
'pointermove': this.pointerMove,
|
||||
'pointerup': this.pointerUp,
|
||||
|
||||
@@ -47,7 +47,7 @@ import Event from '../events/Event.js';
|
||||
* @param {Object.<string, ?>=} opt_eventDict An optional dictionary of
|
||||
* initial event properties.
|
||||
*/
|
||||
var PointerEvent = function(type, originalEvent, opt_eventDict) {
|
||||
const PointerEvent = function(type, originalEvent, opt_eventDict) {
|
||||
Event.call(this, type);
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ var PointerEvent = function(type, originalEvent, opt_eventDict) {
|
||||
*/
|
||||
this.originalEvent = originalEvent;
|
||||
|
||||
var eventDict = opt_eventDict ? opt_eventDict : {};
|
||||
const eventDict = opt_eventDict ? opt_eventDict : {};
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
@@ -222,7 +222,7 @@ PointerEvent.prototype.getButtons_ = function(eventDict) {
|
||||
// is to call initMouseEvent with a buttonArg value of -1.
|
||||
//
|
||||
// This is fixed with DOM Level 4's use of buttons
|
||||
var buttons;
|
||||
let buttons;
|
||||
if (eventDict.buttons || PointerEvent.HAS_BUTTONS) {
|
||||
buttons = eventDict.buttons;
|
||||
} else {
|
||||
@@ -246,7 +246,7 @@ PointerEvent.prototype.getButtons_ = function(eventDict) {
|
||||
PointerEvent.prototype.getPressure_ = function(eventDict, buttons) {
|
||||
// Spec requires that pointers without pressure specified use 0.5 for down
|
||||
// state and 0 for up state.
|
||||
var pressure = 0;
|
||||
let pressure = 0;
|
||||
if (eventDict.pressure) {
|
||||
pressure = eventDict.pressure;
|
||||
} else {
|
||||
@@ -268,7 +268,7 @@ PointerEvent.HAS_BUTTONS = false;
|
||||
*/
|
||||
(function() {
|
||||
try {
|
||||
var ev = new MouseEvent('click', {buttons: 1});
|
||||
const ev = new MouseEvent('click', {buttons: 1});
|
||||
PointerEvent.HAS_BUTTONS = ev.buttons === 1;
|
||||
} catch (e) {
|
||||
// pass
|
||||
|
||||
@@ -47,7 +47,7 @@ import _ol_pointer_TouchSource_ from '../pointer/TouchSource.js';
|
||||
* @extends {ol.events.EventTarget}
|
||||
* @param {Element|HTMLDocument} element Viewport element.
|
||||
*/
|
||||
var PointerEventHandler = function(element) {
|
||||
const PointerEventHandler = function(element) {
|
||||
EventTarget.call(this);
|
||||
|
||||
/**
|
||||
@@ -91,12 +91,12 @@ PointerEventHandler.prototype.registerSources = function() {
|
||||
} else if (_ol_has_.MSPOINTER) {
|
||||
this.registerSource('ms', new _ol_pointer_MsSource_(this));
|
||||
} else {
|
||||
var mouseSource = new _ol_pointer_MouseSource_(this);
|
||||
const mouseSource = new _ol_pointer_MouseSource_(this);
|
||||
this.registerSource('mouse', mouseSource);
|
||||
|
||||
if (_ol_has_.TOUCH) {
|
||||
this.registerSource('touch',
|
||||
new _ol_pointer_TouchSource_(this, mouseSource));
|
||||
new _ol_pointer_TouchSource_(this, mouseSource));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,12 +112,12 @@ PointerEventHandler.prototype.registerSources = function() {
|
||||
* @param {ol.pointer.EventSource} source The source event.
|
||||
*/
|
||||
PointerEventHandler.prototype.registerSource = function(name, source) {
|
||||
var s = source;
|
||||
var newEvents = s.getEvents();
|
||||
const s = source;
|
||||
const newEvents = s.getEvents();
|
||||
|
||||
if (newEvents) {
|
||||
newEvents.forEach(function(e) {
|
||||
var handler = s.getHandlerForEvent(e);
|
||||
const handler = s.getHandlerForEvent(e);
|
||||
|
||||
if (handler) {
|
||||
this.eventMap_[e] = handler.bind(s);
|
||||
@@ -133,9 +133,9 @@ PointerEventHandler.prototype.registerSource = function(name, source) {
|
||||
* @private
|
||||
*/
|
||||
PointerEventHandler.prototype.register_ = function() {
|
||||
var l = this.eventSourceList_.length;
|
||||
var eventSource;
|
||||
for (var i = 0; i < l; i++) {
|
||||
const l = this.eventSourceList_.length;
|
||||
let eventSource;
|
||||
for (let i = 0; i < l; i++) {
|
||||
eventSource = this.eventSourceList_[i];
|
||||
this.addEvents_(eventSource.getEvents());
|
||||
}
|
||||
@@ -147,9 +147,9 @@ PointerEventHandler.prototype.register_ = function() {
|
||||
* @private
|
||||
*/
|
||||
PointerEventHandler.prototype.unregister_ = function() {
|
||||
var l = this.eventSourceList_.length;
|
||||
var eventSource;
|
||||
for (var i = 0; i < l; i++) {
|
||||
const l = this.eventSourceList_.length;
|
||||
let eventSource;
|
||||
for (let i = 0; i < l; i++) {
|
||||
eventSource = this.eventSourceList_[i];
|
||||
this.removeEvents_(eventSource.getEvents());
|
||||
}
|
||||
@@ -162,8 +162,8 @@ PointerEventHandler.prototype.unregister_ = function() {
|
||||
* @param {Event} inEvent Browser event.
|
||||
*/
|
||||
PointerEventHandler.prototype.eventHandler_ = function(inEvent) {
|
||||
var type = inEvent.type;
|
||||
var handler = this.eventMap_[type];
|
||||
const type = inEvent.type;
|
||||
const handler = this.eventMap_[type];
|
||||
if (handler) {
|
||||
handler(inEvent);
|
||||
}
|
||||
@@ -204,9 +204,9 @@ PointerEventHandler.prototype.removeEvents_ = function(events) {
|
||||
* `inEvent`'s properties.
|
||||
*/
|
||||
PointerEventHandler.prototype.cloneEvent = function(event, inEvent) {
|
||||
var eventCopy = {}, p;
|
||||
for (var i = 0, ii = PointerEventHandler.CLONE_PROPS.length; i < ii; i++) {
|
||||
p = PointerEventHandler.CLONE_PROPS[i][0];
|
||||
const eventCopy = {};
|
||||
for (let i = 0, ii = PointerEventHandler.CLONE_PROPS.length; i < ii; i++) {
|
||||
const p = PointerEventHandler.CLONE_PROPS[i][0];
|
||||
eventCopy[p] = event[p] || inEvent[p] || PointerEventHandler.CLONE_PROPS[i][1];
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ PointerEventHandler.prototype.makeEvent = function(inType, data, event) {
|
||||
* @param {Event} event The event.
|
||||
*/
|
||||
PointerEventHandler.prototype.fireEvent = function(inType, data, event) {
|
||||
var e = this.makeEvent(inType, data, event);
|
||||
const e = this.makeEvent(inType, data, event);
|
||||
this.dispatchEvent(e);
|
||||
};
|
||||
|
||||
@@ -375,7 +375,7 @@ PointerEventHandler.prototype.fireEvent = function(inType, data, event) {
|
||||
* @param {Event} event A platform event with a target.
|
||||
*/
|
||||
PointerEventHandler.prototype.fireNativeEvent = function(event) {
|
||||
var e = this.makeEvent(event.type, event, event);
|
||||
const e = this.makeEvent(event.type, event, event);
|
||||
this.dispatchEvent(e);
|
||||
};
|
||||
|
||||
@@ -388,8 +388,8 @@ PointerEventHandler.prototype.fireNativeEvent = function(event) {
|
||||
* @return {ol.pointer.PointerEvent} The wrapped event.
|
||||
*/
|
||||
PointerEventHandler.prototype.wrapMouseEvent = function(eventType, event) {
|
||||
var pointerEvent = this.makeEvent(
|
||||
eventType, _ol_pointer_MouseSource_.prepareEvent(event, this), event);
|
||||
const pointerEvent = this.makeEvent(
|
||||
eventType, _ol_pointer_MouseSource_.prepareEvent(event, this), event);
|
||||
return pointerEvent;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js';
|
||||
* @param {ol.pointer.MouseSource} mouseSource Mouse source.
|
||||
* @extends {ol.pointer.EventSource}
|
||||
*/
|
||||
var _ol_pointer_TouchSource_ = function(dispatcher, mouseSource) {
|
||||
var mapping = {
|
||||
const _ol_pointer_TouchSource_ = function(dispatcher, mouseSource) {
|
||||
const mapping = {
|
||||
'touchstart': this.touchstart,
|
||||
'touchmove': this.touchmove,
|
||||
'touchend': this.touchend,
|
||||
@@ -124,7 +124,7 @@ _ol_pointer_TouchSource_.prototype.isPrimaryTouch_ = function(inTouch) {
|
||||
* @private
|
||||
*/
|
||||
_ol_pointer_TouchSource_.prototype.setPrimaryTouch_ = function(inTouch) {
|
||||
var count = Object.keys(this.pointerMap).length;
|
||||
const count = Object.keys(this.pointerMap).length;
|
||||
if (count === 0 || (count === 1 &&
|
||||
_ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap)) {
|
||||
this.firstTouchId_ = inTouch.identifier;
|
||||
@@ -150,8 +150,8 @@ _ol_pointer_TouchSource_.prototype.removePrimaryPointer_ = function(inPointer) {
|
||||
*/
|
||||
_ol_pointer_TouchSource_.prototype.resetClickCount_ = function() {
|
||||
this.resetId_ = setTimeout(
|
||||
this.resetClickCountHandler_.bind(this),
|
||||
_ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT);
|
||||
this.resetClickCountHandler_.bind(this),
|
||||
_ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT);
|
||||
};
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ _ol_pointer_TouchSource_.prototype.cancelResetClickCount_ = function() {
|
||||
* @return {Object} A pointer object.
|
||||
*/
|
||||
_ol_pointer_TouchSource_.prototype.touchToPointer_ = function(browserEvent, inTouch) {
|
||||
var e = this.dispatcher.cloneEvent(browserEvent, inTouch);
|
||||
const e = this.dispatcher.cloneEvent(browserEvent, inTouch);
|
||||
// Spec specifies that pointerId 1 is reserved for Mouse.
|
||||
// Touch identifiers can start at 0.
|
||||
// Add 2 to the touch identifier for compatibility.
|
||||
@@ -216,13 +216,13 @@ _ol_pointer_TouchSource_.prototype.touchToPointer_ = function(browserEvent, inTo
|
||||
* @param {function(Event, Object)} inFunction In function.
|
||||
*/
|
||||
_ol_pointer_TouchSource_.prototype.processTouches_ = function(inEvent, inFunction) {
|
||||
var touches = Array.prototype.slice.call(
|
||||
inEvent.changedTouches);
|
||||
var count = touches.length;
|
||||
const touches = Array.prototype.slice.call(
|
||||
inEvent.changedTouches);
|
||||
const count = touches.length;
|
||||
function preventDefault() {
|
||||
inEvent.preventDefault();
|
||||
}
|
||||
var i, pointer;
|
||||
let i, pointer;
|
||||
for (i = 0; i < count; ++i) {
|
||||
pointer = this.touchToPointer_(inEvent, touches[i]);
|
||||
// forward touch preventDefaults
|
||||
@@ -239,9 +239,9 @@ _ol_pointer_TouchSource_.prototype.processTouches_ = function(inEvent, inFunctio
|
||||
* @return {boolean} True, if the `Touch` with the given id is in the list.
|
||||
*/
|
||||
_ol_pointer_TouchSource_.prototype.findTouch_ = function(touchList, searchId) {
|
||||
var l = touchList.length;
|
||||
var touch;
|
||||
for (var i = 0; i < l; i++) {
|
||||
const l = touchList.length;
|
||||
let touch;
|
||||
for (let i = 0; i < l; i++) {
|
||||
touch = touchList[i];
|
||||
if (touch.identifier === searchId) {
|
||||
return true;
|
||||
@@ -263,14 +263,14 @@ _ol_pointer_TouchSource_.prototype.findTouch_ = function(touchList, searchId) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_TouchSource_.prototype.vacuumTouches_ = function(inEvent) {
|
||||
var touchList = inEvent.touches;
|
||||
const touchList = inEvent.touches;
|
||||
// pointerMap.getCount() should be < touchList.length here,
|
||||
// as the touchstart has not been processed yet.
|
||||
var keys = Object.keys(this.pointerMap);
|
||||
var count = keys.length;
|
||||
const keys = Object.keys(this.pointerMap);
|
||||
const count = keys.length;
|
||||
if (count >= touchList.length) {
|
||||
var d = [];
|
||||
var i, key, value;
|
||||
const d = [];
|
||||
let i, key, value;
|
||||
for (i = 0; i < count; ++i) {
|
||||
key = keys[i];
|
||||
value = this.pointerMap[key];
|
||||
@@ -338,14 +338,14 @@ _ol_pointer_TouchSource_.prototype.touchmove = function(inEvent) {
|
||||
* @param {Object} inPointer The in pointer.
|
||||
*/
|
||||
_ol_pointer_TouchSource_.prototype.moveOverOut_ = function(browserEvent, inPointer) {
|
||||
var event = inPointer;
|
||||
var pointer = this.pointerMap[event.pointerId];
|
||||
const event = inPointer;
|
||||
const pointer = this.pointerMap[event.pointerId];
|
||||
// a finger drifted off the screen, ignore it
|
||||
if (!pointer) {
|
||||
return;
|
||||
}
|
||||
var outEvent = pointer.out;
|
||||
var outTarget = pointer.outTarget;
|
||||
const outEvent = pointer.out;
|
||||
const outTarget = pointer.outTarget;
|
||||
this.dispatcher.move(event, browserEvent);
|
||||
if (outEvent && outTarget !== event.target) {
|
||||
outEvent.relatedTarget = event.target;
|
||||
@@ -433,12 +433,12 @@ _ol_pointer_TouchSource_.prototype.cleanUpPointer_ = function(inPointer) {
|
||||
* @param {Event} inEvent The in event.
|
||||
*/
|
||||
_ol_pointer_TouchSource_.prototype.dedupSynthMouse_ = function(inEvent) {
|
||||
var lts = this.mouseSource.lastTouches;
|
||||
var t = inEvent.changedTouches[0];
|
||||
const lts = this.mouseSource.lastTouches;
|
||||
const t = inEvent.changedTouches[0];
|
||||
// only the primary finger will synth mouse events
|
||||
if (this.isPrimaryTouch_(t)) {
|
||||
// remember x/y of last touch
|
||||
var lt = [t.clientX, t.clientY];
|
||||
const lt = [t.clientX, t.clientY];
|
||||
lts.push(lt);
|
||||
|
||||
setTimeout(function() {
|
||||
|
||||
Reference in New Issue
Block a user