Merge pull request #7721 from fredj/rename

More renaming
This commit is contained in:
Frédéric Junod
2018-01-19 13:16:21 +01:00
committed by GitHub
8 changed files with 110 additions and 111 deletions

View File

@@ -7,7 +7,7 @@
* mapping.
* @constructor
*/
const _ol_pointer_EventSource_ = function(dispatcher, mapping) {
const EventSource = function(dispatcher, mapping) {
/**
* @type {ol.pointer.PointerEventHandler}
*/
@@ -26,7 +26,7 @@ const _ol_pointer_EventSource_ = function(dispatcher, mapping) {
* List of events supported by this source.
* @return {Array.<string>} Event names
*/
_ol_pointer_EventSource_.prototype.getEvents = function() {
EventSource.prototype.getEvents = function() {
return Object.keys(this.mapping_);
};
@@ -36,7 +36,7 @@ _ol_pointer_EventSource_.prototype.getEvents = function() {
* @param {string} eventType The event type.
* @return {function(Event)} Handler
*/
_ol_pointer_EventSource_.prototype.getHandlerForEvent = function(eventType) {
EventSource.prototype.getHandlerForEvent = function(eventType) {
return this.mapping_[eventType];
};
export default _ol_pointer_EventSource_;
export default EventSource;

View File

@@ -32,14 +32,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import {inherits} from '../index.js';
import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
import EventSource from '../pointer/EventSource.js';
/**
* @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @constructor
* @extends {ol.pointer.EventSource}
*/
const _ol_pointer_MouseSource_ = function(dispatcher) {
const MouseSource = function(dispatcher) {
const mapping = {
'mousedown': this.mousedown,
'mousemove': this.mousemove,
@@ -47,7 +47,7 @@ const _ol_pointer_MouseSource_ = function(dispatcher) {
'mouseover': this.mouseover,
'mouseout': this.mouseout
};
_ol_pointer_EventSource_.call(this, dispatcher, mapping);
EventSource.call(this, dispatcher, mapping);
/**
* @const
@@ -62,21 +62,21 @@ const _ol_pointer_MouseSource_ = function(dispatcher) {
this.lastTouches = [];
};
inherits(_ol_pointer_MouseSource_, _ol_pointer_EventSource_);
inherits(MouseSource, EventSource);
/**
* @const
* @type {number}
*/
_ol_pointer_MouseSource_.POINTER_ID = 1;
MouseSource.POINTER_ID = 1;
/**
* @const
* @type {string}
*/
_ol_pointer_MouseSource_.POINTER_TYPE = 'mouse';
MouseSource.POINTER_TYPE = 'mouse';
/**
@@ -85,7 +85,7 @@ _ol_pointer_MouseSource_.POINTER_TYPE = 'mouse';
* @const
* @type {number}
*/
_ol_pointer_MouseSource_.DEDUP_DIST = 25;
MouseSource.DEDUP_DIST = 25;
/**
@@ -112,7 +112,7 @@ _ol_pointer_MouseSource_.DEDUP_DIST = 25;
* @param {Event} inEvent The in event.
* @return {boolean} True, if the event was generated by a touch.
*/
_ol_pointer_MouseSource_.prototype.isEventSimulatedFromTouch_ = function(inEvent) {
MouseSource.prototype.isEventSimulatedFromTouch_ = function(inEvent) {
const lts = this.lastTouches;
const x = inEvent.clientX;
const y = inEvent.clientY;
@@ -120,8 +120,8 @@ _ol_pointer_MouseSource_.prototype.isEventSimulatedFromTouch_ = function(inEvent
// simulated mouse events will be swallowed near a primary touchend
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) {
if (dx <= MouseSource.DEDUP_DIST &&
dy <= MouseSource.DEDUP_DIST) {
return true;
}
}
@@ -137,7 +137,7 @@ _ol_pointer_MouseSource_.prototype.isEventSimulatedFromTouch_ = function(inEvent
* @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @return {Object} The copied event.
*/
_ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) {
MouseSource.prepareEvent = function(inEvent, dispatcher) {
const e = dispatcher.cloneEvent(inEvent, inEvent);
// forward mouse preventDefault
@@ -147,9 +147,9 @@ _ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) {
pd();
};
e.pointerId = _ol_pointer_MouseSource_.POINTER_ID;
e.pointerId = MouseSource.POINTER_ID;
e.isPrimary = true;
e.pointerType = _ol_pointer_MouseSource_.POINTER_TYPE;
e.pointerType = MouseSource.POINTER_TYPE;
return e;
};
@@ -160,15 +160,15 @@ _ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MouseSource_.prototype.mousedown = function(inEvent) {
MouseSource.prototype.mousedown = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
// TODO(dfreedman) workaround for some elements not sending mouseup
// http://crbug/149091
if (_ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap) {
if (MouseSource.POINTER_ID.toString() in this.pointerMap) {
this.cancel(inEvent);
}
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()] = inEvent;
const e = MouseSource.prepareEvent(inEvent, this.dispatcher);
this.pointerMap[MouseSource.POINTER_ID.toString()] = inEvent;
this.dispatcher.down(e, inEvent);
}
};
@@ -179,9 +179,9 @@ _ol_pointer_MouseSource_.prototype.mousedown = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) {
MouseSource.prototype.mousemove = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = MouseSource.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.move(e, inEvent);
}
};
@@ -192,12 +192,12 @@ _ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) {
MouseSource.prototype.mouseup = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const p = this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()];
const p = this.pointerMap[MouseSource.POINTER_ID.toString()];
if (p && p.button === inEvent.button) {
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = MouseSource.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.up(e, inEvent);
this.cleanupMouse();
}
@@ -210,9 +210,9 @@ _ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) {
MouseSource.prototype.mouseover = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = MouseSource.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.enterOver(e, inEvent);
}
};
@@ -223,9 +223,9 @@ _ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) {
MouseSource.prototype.mouseout = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = MouseSource.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.leaveOut(e, inEvent);
}
};
@@ -236,8 +236,8 @@ _ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MouseSource_.prototype.cancel = function(inEvent) {
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
MouseSource.prototype.cancel = function(inEvent) {
const e = MouseSource.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.cancel(e, inEvent);
this.cleanupMouse();
};
@@ -246,7 +246,7 @@ _ol_pointer_MouseSource_.prototype.cancel = function(inEvent) {
/**
* Remove the mouse from the list of active pointers.
*/
_ol_pointer_MouseSource_.prototype.cleanupMouse = function() {
delete this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()];
MouseSource.prototype.cleanupMouse = function() {
delete this.pointerMap[MouseSource.POINTER_ID.toString()];
};
export default _ol_pointer_MouseSource_;
export default MouseSource;

View File

@@ -32,14 +32,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import {inherits} from '../index.js';
import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
import EventSource from '../pointer/EventSource.js';
/**
* @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @constructor
* @extends {ol.pointer.EventSource}
*/
const _ol_pointer_MsSource_ = function(dispatcher) {
const MsSource = function(dispatcher) {
const mapping = {
'MSPointerDown': this.msPointerDown,
'MSPointerMove': this.msPointerMove,
@@ -50,7 +50,7 @@ const _ol_pointer_MsSource_ = function(dispatcher) {
'MSGotPointerCapture': this.msGotPointerCapture,
'MSLostPointerCapture': this.msLostPointerCapture
};
_ol_pointer_EventSource_.call(this, dispatcher, mapping);
EventSource.call(this, dispatcher, mapping);
/**
* @const
@@ -71,7 +71,7 @@ const _ol_pointer_MsSource_ = function(dispatcher) {
];
};
inherits(_ol_pointer_MsSource_, _ol_pointer_EventSource_);
inherits(MsSource, EventSource);
/**
@@ -82,7 +82,7 @@ inherits(_ol_pointer_MsSource_, _ol_pointer_EventSource_);
* @param {Event} inEvent The in event.
* @return {Object} The copied event.
*/
_ol_pointer_MsSource_.prototype.prepareEvent_ = function(inEvent) {
MsSource.prototype.prepareEvent_ = function(inEvent) {
let e = inEvent;
if (typeof inEvent.pointerType === 'number') {
e = this.dispatcher.cloneEvent(inEvent, inEvent);
@@ -97,7 +97,7 @@ _ol_pointer_MsSource_.prototype.prepareEvent_ = function(inEvent) {
* Remove this pointer from the list of active pointers.
* @param {number} pointerId Pointer identifier.
*/
_ol_pointer_MsSource_.prototype.cleanup = function(pointerId) {
MsSource.prototype.cleanup = function(pointerId) {
delete this.pointerMap[pointerId.toString()];
};
@@ -107,7 +107,7 @@ _ol_pointer_MsSource_.prototype.cleanup = function(pointerId) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MsSource_.prototype.msPointerDown = function(inEvent) {
MsSource.prototype.msPointerDown = function(inEvent) {
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
const e = this.prepareEvent_(inEvent);
this.dispatcher.down(e, inEvent);
@@ -119,7 +119,7 @@ _ol_pointer_MsSource_.prototype.msPointerDown = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MsSource_.prototype.msPointerMove = function(inEvent) {
MsSource.prototype.msPointerMove = function(inEvent) {
const e = this.prepareEvent_(inEvent);
this.dispatcher.move(e, inEvent);
};
@@ -130,7 +130,7 @@ _ol_pointer_MsSource_.prototype.msPointerMove = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MsSource_.prototype.msPointerUp = function(inEvent) {
MsSource.prototype.msPointerUp = function(inEvent) {
const e = this.prepareEvent_(inEvent);
this.dispatcher.up(e, inEvent);
this.cleanup(inEvent.pointerId);
@@ -142,7 +142,7 @@ _ol_pointer_MsSource_.prototype.msPointerUp = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MsSource_.prototype.msPointerOut = function(inEvent) {
MsSource.prototype.msPointerOut = function(inEvent) {
const e = this.prepareEvent_(inEvent);
this.dispatcher.leaveOut(e, inEvent);
};
@@ -153,7 +153,7 @@ _ol_pointer_MsSource_.prototype.msPointerOut = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MsSource_.prototype.msPointerOver = function(inEvent) {
MsSource.prototype.msPointerOver = function(inEvent) {
const e = this.prepareEvent_(inEvent);
this.dispatcher.enterOver(e, inEvent);
};
@@ -164,7 +164,7 @@ _ol_pointer_MsSource_.prototype.msPointerOver = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MsSource_.prototype.msPointerCancel = function(inEvent) {
MsSource.prototype.msPointerCancel = function(inEvent) {
const e = this.prepareEvent_(inEvent);
this.dispatcher.cancel(e, inEvent);
this.cleanup(inEvent.pointerId);
@@ -176,7 +176,7 @@ _ol_pointer_MsSource_.prototype.msPointerCancel = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MsSource_.prototype.msLostPointerCapture = function(inEvent) {
MsSource.prototype.msLostPointerCapture = function(inEvent) {
const e = this.dispatcher.makeEvent('lostpointercapture',
inEvent, inEvent);
this.dispatcher.dispatchEvent(e);
@@ -188,9 +188,9 @@ _ol_pointer_MsSource_.prototype.msLostPointerCapture = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_MsSource_.prototype.msGotPointerCapture = function(inEvent) {
MsSource.prototype.msGotPointerCapture = function(inEvent) {
const e = this.dispatcher.makeEvent('gotpointercapture',
inEvent, inEvent);
this.dispatcher.dispatchEvent(e);
};
export default _ol_pointer_MsSource_;
export default MsSource;

View File

@@ -32,14 +32,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import {inherits} from '../index.js';
import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
import EventSource from '../pointer/EventSource.js';
/**
* @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @constructor
* @extends {ol.pointer.EventSource}
*/
const _ol_pointer_NativeSource_ = function(dispatcher) {
const NativeSource = function(dispatcher) {
const mapping = {
'pointerdown': this.pointerDown,
'pointermove': this.pointerMove,
@@ -50,10 +50,10 @@ const _ol_pointer_NativeSource_ = function(dispatcher) {
'gotpointercapture': this.gotPointerCapture,
'lostpointercapture': this.lostPointerCapture
};
_ol_pointer_EventSource_.call(this, dispatcher, mapping);
EventSource.call(this, dispatcher, mapping);
};
inherits(_ol_pointer_NativeSource_, _ol_pointer_EventSource_);
inherits(NativeSource, EventSource);
/**
@@ -61,7 +61,7 @@ inherits(_ol_pointer_NativeSource_, _ol_pointer_EventSource_);
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_NativeSource_.prototype.pointerDown = function(inEvent) {
NativeSource.prototype.pointerDown = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -71,7 +71,7 @@ _ol_pointer_NativeSource_.prototype.pointerDown = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_NativeSource_.prototype.pointerMove = function(inEvent) {
NativeSource.prototype.pointerMove = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -81,7 +81,7 @@ _ol_pointer_NativeSource_.prototype.pointerMove = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_NativeSource_.prototype.pointerUp = function(inEvent) {
NativeSource.prototype.pointerUp = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -91,7 +91,7 @@ _ol_pointer_NativeSource_.prototype.pointerUp = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_NativeSource_.prototype.pointerOut = function(inEvent) {
NativeSource.prototype.pointerOut = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -101,7 +101,7 @@ _ol_pointer_NativeSource_.prototype.pointerOut = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_NativeSource_.prototype.pointerOver = function(inEvent) {
NativeSource.prototype.pointerOver = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -111,7 +111,7 @@ _ol_pointer_NativeSource_.prototype.pointerOver = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_NativeSource_.prototype.pointerCancel = function(inEvent) {
NativeSource.prototype.pointerCancel = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -121,7 +121,7 @@ _ol_pointer_NativeSource_.prototype.pointerCancel = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_NativeSource_.prototype.lostPointerCapture = function(inEvent) {
NativeSource.prototype.lostPointerCapture = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -131,7 +131,7 @@ _ol_pointer_NativeSource_.prototype.lostPointerCapture = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_NativeSource_.prototype.gotPointerCapture = function(inEvent) {
NativeSource.prototype.gotPointerCapture = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
export default _ol_pointer_NativeSource_;
export default NativeSource;

View File

@@ -36,11 +36,11 @@ import _ol_events_ from '../events.js';
import EventTarget from '../events/EventTarget.js';
import _ol_has_ from '../has.js';
import PointerEventType from '../pointer/EventType.js';
import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js';
import _ol_pointer_MsSource_ from '../pointer/MsSource.js';
import _ol_pointer_NativeSource_ from '../pointer/NativeSource.js';
import MouseSource from '../pointer/MouseSource.js';
import MsSource from '../pointer/MsSource.js';
import NativeSource from '../pointer/NativeSource.js';
import PointerEvent from '../pointer/PointerEvent.js';
import _ol_pointer_TouchSource_ from '../pointer/TouchSource.js';
import TouchSource from '../pointer/TouchSource.js';
/**
* @constructor
@@ -87,16 +87,15 @@ inherits(PointerEventHandler, EventTarget);
*/
PointerEventHandler.prototype.registerSources = function() {
if (_ol_has_.POINTER) {
this.registerSource('native', new _ol_pointer_NativeSource_(this));
this.registerSource('native', new NativeSource(this));
} else if (_ol_has_.MSPOINTER) {
this.registerSource('ms', new _ol_pointer_MsSource_(this));
this.registerSource('ms', new MsSource(this));
} else {
const mouseSource = new _ol_pointer_MouseSource_(this);
const mouseSource = new MouseSource(this);
this.registerSource('mouse', mouseSource);
if (_ol_has_.TOUCH) {
this.registerSource('touch',
new _ol_pointer_TouchSource_(this, mouseSource));
this.registerSource('touch', new TouchSource(this, mouseSource));
}
}
@@ -389,7 +388,7 @@ PointerEventHandler.prototype.fireNativeEvent = function(event) {
*/
PointerEventHandler.prototype.wrapMouseEvent = function(eventType, event) {
const pointerEvent = this.makeEvent(
eventType, _ol_pointer_MouseSource_.prepareEvent(event, this), event);
eventType, MouseSource.prepareEvent(event, this), event);
return pointerEvent;
};

View File

@@ -33,8 +33,8 @@
import {inherits} from '../index.js';
import {remove} from '../array.js';
import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js';
import EventSource from '../pointer/EventSource.js';
import MouseSource from '../pointer/MouseSource.js';
/**
* @constructor
@@ -42,14 +42,14 @@ import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js';
* @param {ol.pointer.MouseSource} mouseSource Mouse source.
* @extends {ol.pointer.EventSource}
*/
const _ol_pointer_TouchSource_ = function(dispatcher, mouseSource) {
const TouchSource = function(dispatcher, mouseSource) {
const mapping = {
'touchstart': this.touchstart,
'touchmove': this.touchmove,
'touchend': this.touchend,
'touchcancel': this.touchcancel
};
_ol_pointer_EventSource_.call(this, dispatcher, mapping);
EventSource.call(this, dispatcher, mapping);
/**
* @const
@@ -82,7 +82,7 @@ const _ol_pointer_TouchSource_ = function(dispatcher, mouseSource) {
this.resetId_ = undefined;
};
inherits(_ol_pointer_TouchSource_, _ol_pointer_EventSource_);
inherits(TouchSource, EventSource);
/**
@@ -91,21 +91,21 @@ inherits(_ol_pointer_TouchSource_, _ol_pointer_EventSource_);
* @const
* @type {number}
*/
_ol_pointer_TouchSource_.DEDUP_TIMEOUT = 2500;
TouchSource.DEDUP_TIMEOUT = 2500;
/**
* @const
* @type {number}
*/
_ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT = 200;
TouchSource.CLICK_COUNT_TIMEOUT = 200;
/**
* @const
* @type {string}
*/
_ol_pointer_TouchSource_.POINTER_TYPE = 'touch';
TouchSource.POINTER_TYPE = 'touch';
/**
@@ -113,7 +113,7 @@ _ol_pointer_TouchSource_.POINTER_TYPE = 'touch';
* @param {Touch} inTouch The in touch.
* @return {boolean} True, if this is the primary touch.
*/
_ol_pointer_TouchSource_.prototype.isPrimaryTouch_ = function(inTouch) {
TouchSource.prototype.isPrimaryTouch_ = function(inTouch) {
return this.firstTouchId_ === inTouch.identifier;
};
@@ -123,10 +123,10 @@ _ol_pointer_TouchSource_.prototype.isPrimaryTouch_ = function(inTouch) {
* @param {Touch} inTouch The in touch.
* @private
*/
_ol_pointer_TouchSource_.prototype.setPrimaryTouch_ = function(inTouch) {
TouchSource.prototype.setPrimaryTouch_ = function(inTouch) {
const count = Object.keys(this.pointerMap).length;
if (count === 0 || (count === 1 &&
_ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap)) {
MouseSource.POINTER_ID.toString() in this.pointerMap)) {
this.firstTouchId_ = inTouch.identifier;
this.cancelResetClickCount_();
}
@@ -137,7 +137,7 @@ _ol_pointer_TouchSource_.prototype.setPrimaryTouch_ = function(inTouch) {
* @private
* @param {Object} inPointer The in pointer object.
*/
_ol_pointer_TouchSource_.prototype.removePrimaryPointer_ = function(inPointer) {
TouchSource.prototype.removePrimaryPointer_ = function(inPointer) {
if (inPointer.isPrimary) {
this.firstTouchId_ = undefined;
this.resetClickCount_();
@@ -148,17 +148,17 @@ _ol_pointer_TouchSource_.prototype.removePrimaryPointer_ = function(inPointer) {
/**
* @private
*/
_ol_pointer_TouchSource_.prototype.resetClickCount_ = function() {
TouchSource.prototype.resetClickCount_ = function() {
this.resetId_ = setTimeout(
this.resetClickCountHandler_.bind(this),
_ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT);
TouchSource.CLICK_COUNT_TIMEOUT);
};
/**
* @private
*/
_ol_pointer_TouchSource_.prototype.resetClickCountHandler_ = function() {
TouchSource.prototype.resetClickCountHandler_ = function() {
this.clickCount_ = 0;
this.resetId_ = undefined;
};
@@ -167,7 +167,7 @@ _ol_pointer_TouchSource_.prototype.resetClickCountHandler_ = function() {
/**
* @private
*/
_ol_pointer_TouchSource_.prototype.cancelResetClickCount_ = function() {
TouchSource.prototype.cancelResetClickCount_ = function() {
if (this.resetId_ !== undefined) {
clearTimeout(this.resetId_);
}
@@ -180,7 +180,7 @@ _ol_pointer_TouchSource_.prototype.cancelResetClickCount_ = function() {
* @param {Touch} inTouch Touch event
* @return {Object} A pointer object.
*/
_ol_pointer_TouchSource_.prototype.touchToPointer_ = function(browserEvent, inTouch) {
TouchSource.prototype.touchToPointer_ = function(browserEvent, inTouch) {
const e = this.dispatcher.cloneEvent(browserEvent, inTouch);
// Spec specifies that pointerId 1 is reserved for Mouse.
// Touch identifiers can start at 0.
@@ -197,7 +197,7 @@ _ol_pointer_TouchSource_.prototype.touchToPointer_ = function(browserEvent, inTo
e.height = inTouch.webkitRadiusY || inTouch.radiusY || 0;
e.pressure = inTouch.webkitForce || inTouch.force || 0.5;
e.isPrimary = this.isPrimaryTouch_(inTouch);
e.pointerType = _ol_pointer_TouchSource_.POINTER_TYPE;
e.pointerType = TouchSource.POINTER_TYPE;
// make sure that the properties that are different for
// each `Touch` object are not copied from the BrowserEvent object
@@ -215,7 +215,7 @@ _ol_pointer_TouchSource_.prototype.touchToPointer_ = function(browserEvent, inTo
* @param {Event} inEvent Touch event
* @param {function(Event, Object)} inFunction In function.
*/
_ol_pointer_TouchSource_.prototype.processTouches_ = function(inEvent, inFunction) {
TouchSource.prototype.processTouches_ = function(inEvent, inFunction) {
const touches = Array.prototype.slice.call(
inEvent.changedTouches);
const count = touches.length;
@@ -238,7 +238,7 @@ _ol_pointer_TouchSource_.prototype.processTouches_ = function(inEvent, inFunctio
* @param {number} searchId Search identifier.
* @return {boolean} True, if the `Touch` with the given id is in the list.
*/
_ol_pointer_TouchSource_.prototype.findTouch_ = function(touchList, searchId) {
TouchSource.prototype.findTouch_ = function(touchList, searchId) {
const l = touchList.length;
let touch;
for (let i = 0; i < l; i++) {
@@ -262,7 +262,7 @@ _ol_pointer_TouchSource_.prototype.findTouch_ = function(touchList, searchId) {
* @private
* @param {Event} inEvent The in event.
*/
_ol_pointer_TouchSource_.prototype.vacuumTouches_ = function(inEvent) {
TouchSource.prototype.vacuumTouches_ = function(inEvent) {
const touchList = inEvent.touches;
// pointerMap.getCount() should be < touchList.length here,
// as the touchstart has not been processed yet.
@@ -277,7 +277,7 @@ _ol_pointer_TouchSource_.prototype.vacuumTouches_ = function(inEvent) {
// Never remove pointerId == 1, which is mouse.
// Touch identifiers are 2 smaller than their pointerId, which is the
// index in pointermap.
if (key != _ol_pointer_MouseSource_.POINTER_ID &&
if (key != MouseSource.POINTER_ID &&
!this.findTouch_(touchList, key - 2)) {
d.push(value.out);
}
@@ -295,7 +295,7 @@ _ol_pointer_TouchSource_.prototype.vacuumTouches_ = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_TouchSource_.prototype.touchstart = function(inEvent) {
TouchSource.prototype.touchstart = function(inEvent) {
this.vacuumTouches_(inEvent);
this.setPrimaryTouch_(inEvent.changedTouches[0]);
this.dedupSynthMouse_(inEvent);
@@ -309,7 +309,7 @@ _ol_pointer_TouchSource_.prototype.touchstart = function(inEvent) {
* @param {Event} browserEvent The event.
* @param {Object} inPointer The in pointer object.
*/
_ol_pointer_TouchSource_.prototype.overDown_ = function(browserEvent, inPointer) {
TouchSource.prototype.overDown_ = function(browserEvent, inPointer) {
this.pointerMap[inPointer.pointerId] = {
target: inPointer.target,
out: inPointer,
@@ -326,7 +326,7 @@ _ol_pointer_TouchSource_.prototype.overDown_ = function(browserEvent, inPointer)
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_TouchSource_.prototype.touchmove = function(inEvent) {
TouchSource.prototype.touchmove = function(inEvent) {
inEvent.preventDefault();
this.processTouches_(inEvent, this.moveOverOut_);
};
@@ -337,7 +337,7 @@ _ol_pointer_TouchSource_.prototype.touchmove = function(inEvent) {
* @param {Event} browserEvent The event.
* @param {Object} inPointer The in pointer.
*/
_ol_pointer_TouchSource_.prototype.moveOverOut_ = function(browserEvent, inPointer) {
TouchSource.prototype.moveOverOut_ = function(browserEvent, inPointer) {
const event = inPointer;
const pointer = this.pointerMap[event.pointerId];
// a finger drifted off the screen, ignore it
@@ -373,7 +373,7 @@ _ol_pointer_TouchSource_.prototype.moveOverOut_ = function(browserEvent, inPoint
*
* @param {Event} inEvent The event.
*/
_ol_pointer_TouchSource_.prototype.touchend = function(inEvent) {
TouchSource.prototype.touchend = function(inEvent) {
this.dedupSynthMouse_(inEvent);
this.processTouches_(inEvent, this.upOut_);
};
@@ -384,7 +384,7 @@ _ol_pointer_TouchSource_.prototype.touchend = function(inEvent) {
* @param {Event} browserEvent An event.
* @param {Object} inPointer The inPointer object.
*/
_ol_pointer_TouchSource_.prototype.upOut_ = function(browserEvent, inPointer) {
TouchSource.prototype.upOut_ = function(browserEvent, inPointer) {
this.dispatcher.up(inPointer, browserEvent);
this.dispatcher.out(inPointer, browserEvent);
this.dispatcher.leave(inPointer, browserEvent);
@@ -398,7 +398,7 @@ _ol_pointer_TouchSource_.prototype.upOut_ = function(browserEvent, inPointer) {
*
* @param {Event} inEvent The in event.
*/
_ol_pointer_TouchSource_.prototype.touchcancel = function(inEvent) {
TouchSource.prototype.touchcancel = function(inEvent) {
this.processTouches_(inEvent, this.cancelOut_);
};
@@ -408,7 +408,7 @@ _ol_pointer_TouchSource_.prototype.touchcancel = function(inEvent) {
* @param {Event} browserEvent The event.
* @param {Object} inPointer The in pointer.
*/
_ol_pointer_TouchSource_.prototype.cancelOut_ = function(browserEvent, inPointer) {
TouchSource.prototype.cancelOut_ = function(browserEvent, inPointer) {
this.dispatcher.cancel(inPointer, browserEvent);
this.dispatcher.out(inPointer, browserEvent);
this.dispatcher.leave(inPointer, browserEvent);
@@ -420,7 +420,7 @@ _ol_pointer_TouchSource_.prototype.cancelOut_ = function(browserEvent, inPointer
* @private
* @param {Object} inPointer The inPointer object.
*/
_ol_pointer_TouchSource_.prototype.cleanUpPointer_ = function(inPointer) {
TouchSource.prototype.cleanUpPointer_ = function(inPointer) {
delete this.pointerMap[inPointer.pointerId];
this.removePrimaryPointer_(inPointer);
};
@@ -432,7 +432,7 @@ _ol_pointer_TouchSource_.prototype.cleanUpPointer_ = function(inPointer) {
* @private
* @param {Event} inEvent The in event.
*/
_ol_pointer_TouchSource_.prototype.dedupSynthMouse_ = function(inEvent) {
TouchSource.prototype.dedupSynthMouse_ = function(inEvent) {
const lts = this.mouseSource.lastTouches;
const t = inEvent.changedTouches[0];
// only the primary finger will synth mouse events
@@ -444,7 +444,7 @@ _ol_pointer_TouchSource_.prototype.dedupSynthMouse_ = function(inEvent) {
setTimeout(function() {
// remove touch after timeout
remove(lts, lt);
}, _ol_pointer_TouchSource_.DEDUP_TIMEOUT);
}, TouchSource.DEDUP_TIMEOUT);
}
};
export default _ol_pointer_TouchSource_;
export default TouchSource;

View File

@@ -2,7 +2,7 @@ import _ol_events_ from '../../../../src/ol/events.js';
import EventTarget from '../../../../src/ol/events/EventTarget.js';
import _ol_has_ from '../../../../src/ol/has.js';
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.js';
import _ol_pointer_TouchSource_ from '../../../../src/ol/pointer/TouchSource.js';
import TouchSource from '../../../../src/ol/pointer/TouchSource.js';
describe('ol.pointer.MouseSource', function() {
@@ -53,7 +53,7 @@ describe('ol.pointer.MouseSource', function() {
it('dispatches real mouse events after timeout', function() {
// set the timeout to a lower value, to speed up the tests
_ol_pointer_TouchSource_.DEDUP_TIMEOUT = 100;
TouchSource.DEDUP_TIMEOUT = 100;
_ol_events_.listen(handler, 'pointerdown', eventSpy);

View File

@@ -1,7 +1,7 @@
import _ol_events_ from '../../../../src/ol/events.js';
import EventTarget from '../../../../src/ol/events/EventTarget.js';
import _ol_has_ from '../../../../src/ol/has.js';
import _ol_pointer_MouseSource_ from '../../../../src/ol/pointer/MouseSource.js';
import MouseSource from '../../../../src/ol/pointer/MouseSource.js';
import PointerEvent from '../../../../src/ol/pointer/PointerEvent.js';
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.js';
@@ -30,7 +30,7 @@ describe('ol.pointer.PointerEventHandler', function() {
describe('constructor', function() {
it('registers a least one event source', function() {
expect(handler.eventSourceList_.length).to.be.greaterThan(0);
expect(handler.eventSourceList_[0]).to.be.a(_ol_pointer_MouseSource_);
expect(handler.eventSourceList_[0]).to.be.a(MouseSource);
});
});