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
+4 -4
View File
@@ -7,7 +7,7 @@
* mapping. * mapping.
* @constructor * @constructor
*/ */
const _ol_pointer_EventSource_ = function(dispatcher, mapping) { const EventSource = function(dispatcher, mapping) {
/** /**
* @type {ol.pointer.PointerEventHandler} * @type {ol.pointer.PointerEventHandler}
*/ */
@@ -26,7 +26,7 @@ const _ol_pointer_EventSource_ = function(dispatcher, mapping) {
* List of events supported by this source. * List of events supported by this source.
* @return {Array.<string>} Event names * @return {Array.<string>} Event names
*/ */
_ol_pointer_EventSource_.prototype.getEvents = function() { EventSource.prototype.getEvents = function() {
return Object.keys(this.mapping_); return Object.keys(this.mapping_);
}; };
@@ -36,7 +36,7 @@ _ol_pointer_EventSource_.prototype.getEvents = function() {
* @param {string} eventType The event type. * @param {string} eventType The event type.
* @return {function(Event)} Handler * @return {function(Event)} Handler
*/ */
_ol_pointer_EventSource_.prototype.getHandlerForEvent = function(eventType) { EventSource.prototype.getHandlerForEvent = function(eventType) {
return this.mapping_[eventType]; return this.mapping_[eventType];
}; };
export default _ol_pointer_EventSource_; export default EventSource;
+31 -31
View File
@@ -32,14 +32,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import {inherits} from '../index.js'; 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. * @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @constructor * @constructor
* @extends {ol.pointer.EventSource} * @extends {ol.pointer.EventSource}
*/ */
const _ol_pointer_MouseSource_ = function(dispatcher) { const MouseSource = function(dispatcher) {
const mapping = { const mapping = {
'mousedown': this.mousedown, 'mousedown': this.mousedown,
'mousemove': this.mousemove, 'mousemove': this.mousemove,
@@ -47,7 +47,7 @@ const _ol_pointer_MouseSource_ = function(dispatcher) {
'mouseover': this.mouseover, 'mouseover': this.mouseover,
'mouseout': this.mouseout 'mouseout': this.mouseout
}; };
_ol_pointer_EventSource_.call(this, dispatcher, mapping); EventSource.call(this, dispatcher, mapping);
/** /**
* @const * @const
@@ -62,21 +62,21 @@ const _ol_pointer_MouseSource_ = function(dispatcher) {
this.lastTouches = []; this.lastTouches = [];
}; };
inherits(_ol_pointer_MouseSource_, _ol_pointer_EventSource_); inherits(MouseSource, EventSource);
/** /**
* @const * @const
* @type {number} * @type {number}
*/ */
_ol_pointer_MouseSource_.POINTER_ID = 1; MouseSource.POINTER_ID = 1;
/** /**
* @const * @const
* @type {string} * @type {string}
*/ */
_ol_pointer_MouseSource_.POINTER_TYPE = 'mouse'; MouseSource.POINTER_TYPE = 'mouse';
/** /**
@@ -85,7 +85,7 @@ _ol_pointer_MouseSource_.POINTER_TYPE = 'mouse';
* @const * @const
* @type {number} * @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. * @param {Event} inEvent The in event.
* @return {boolean} True, if the event was generated by a touch. * @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 lts = this.lastTouches;
const x = inEvent.clientX; const x = inEvent.clientX;
const y = inEvent.clientY; 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 // simulated mouse events will be swallowed near a primary touchend
const dx = Math.abs(x - t[0]); const dx = Math.abs(x - t[0]);
const dy = Math.abs(y - t[1]); const dy = Math.abs(y - t[1]);
if (dx <= _ol_pointer_MouseSource_.DEDUP_DIST && if (dx <= MouseSource.DEDUP_DIST &&
dy <= _ol_pointer_MouseSource_.DEDUP_DIST) { dy <= MouseSource.DEDUP_DIST) {
return true; return true;
} }
} }
@@ -137,7 +137,7 @@ _ol_pointer_MouseSource_.prototype.isEventSimulatedFromTouch_ = function(inEvent
* @param {ol.pointer.PointerEventHandler} dispatcher Event handler. * @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @return {Object} The copied event. * @return {Object} The copied event.
*/ */
_ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) { MouseSource.prepareEvent = function(inEvent, dispatcher) {
const e = dispatcher.cloneEvent(inEvent, inEvent); const e = dispatcher.cloneEvent(inEvent, inEvent);
// forward mouse preventDefault // forward mouse preventDefault
@@ -147,9 +147,9 @@ _ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) {
pd(); pd();
}; };
e.pointerId = _ol_pointer_MouseSource_.POINTER_ID; e.pointerId = MouseSource.POINTER_ID;
e.isPrimary = true; e.isPrimary = true;
e.pointerType = _ol_pointer_MouseSource_.POINTER_TYPE; e.pointerType = MouseSource.POINTER_TYPE;
return e; return e;
}; };
@@ -160,15 +160,15 @@ _ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MouseSource_.prototype.mousedown = function(inEvent) { MouseSource.prototype.mousedown = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) { if (!this.isEventSimulatedFromTouch_(inEvent)) {
// TODO(dfreedman) workaround for some elements not sending mouseup // TODO(dfreedman) workaround for some elements not sending mouseup
// http://crbug/149091 // http://crbug/149091
if (_ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap) { if (MouseSource.POINTER_ID.toString() in this.pointerMap) {
this.cancel(inEvent); this.cancel(inEvent);
} }
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher); const e = MouseSource.prepareEvent(inEvent, this.dispatcher);
this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()] = inEvent; this.pointerMap[MouseSource.POINTER_ID.toString()] = inEvent;
this.dispatcher.down(e, inEvent); this.dispatcher.down(e, inEvent);
} }
}; };
@@ -179,9 +179,9 @@ _ol_pointer_MouseSource_.prototype.mousedown = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) { MouseSource.prototype.mousemove = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(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); this.dispatcher.move(e, inEvent);
} }
}; };
@@ -192,12 +192,12 @@ _ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) { MouseSource.prototype.mouseup = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(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) { 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.dispatcher.up(e, inEvent);
this.cleanupMouse(); this.cleanupMouse();
} }
@@ -210,9 +210,9 @@ _ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) { MouseSource.prototype.mouseover = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(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); this.dispatcher.enterOver(e, inEvent);
} }
}; };
@@ -223,9 +223,9 @@ _ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) { MouseSource.prototype.mouseout = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(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); this.dispatcher.leaveOut(e, inEvent);
} }
}; };
@@ -236,8 +236,8 @@ _ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MouseSource_.prototype.cancel = function(inEvent) { MouseSource.prototype.cancel = function(inEvent) {
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher); const e = MouseSource.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.cancel(e, inEvent); this.dispatcher.cancel(e, inEvent);
this.cleanupMouse(); this.cleanupMouse();
}; };
@@ -246,7 +246,7 @@ _ol_pointer_MouseSource_.prototype.cancel = function(inEvent) {
/** /**
* Remove the mouse from the list of active pointers. * Remove the mouse from the list of active pointers.
*/ */
_ol_pointer_MouseSource_.prototype.cleanupMouse = function() { MouseSource.prototype.cleanupMouse = function() {
delete this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()]; delete this.pointerMap[MouseSource.POINTER_ID.toString()];
}; };
export default _ol_pointer_MouseSource_; export default MouseSource;
+15 -15
View File
@@ -32,14 +32,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import {inherits} from '../index.js'; 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. * @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @constructor * @constructor
* @extends {ol.pointer.EventSource} * @extends {ol.pointer.EventSource}
*/ */
const _ol_pointer_MsSource_ = function(dispatcher) { const MsSource = function(dispatcher) {
const mapping = { const mapping = {
'MSPointerDown': this.msPointerDown, 'MSPointerDown': this.msPointerDown,
'MSPointerMove': this.msPointerMove, 'MSPointerMove': this.msPointerMove,
@@ -50,7 +50,7 @@ const _ol_pointer_MsSource_ = function(dispatcher) {
'MSGotPointerCapture': this.msGotPointerCapture, 'MSGotPointerCapture': this.msGotPointerCapture,
'MSLostPointerCapture': this.msLostPointerCapture 'MSLostPointerCapture': this.msLostPointerCapture
}; };
_ol_pointer_EventSource_.call(this, dispatcher, mapping); EventSource.call(this, dispatcher, mapping);
/** /**
* @const * @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. * @param {Event} inEvent The in event.
* @return {Object} The copied event. * @return {Object} The copied event.
*/ */
_ol_pointer_MsSource_.prototype.prepareEvent_ = function(inEvent) { MsSource.prototype.prepareEvent_ = function(inEvent) {
let e = inEvent; let e = inEvent;
if (typeof inEvent.pointerType === 'number') { if (typeof inEvent.pointerType === 'number') {
e = this.dispatcher.cloneEvent(inEvent, inEvent); 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. * Remove this pointer from the list of active pointers.
* @param {number} pointerId Pointer identifier. * @param {number} pointerId Pointer identifier.
*/ */
_ol_pointer_MsSource_.prototype.cleanup = function(pointerId) { MsSource.prototype.cleanup = function(pointerId) {
delete this.pointerMap[pointerId.toString()]; delete this.pointerMap[pointerId.toString()];
}; };
@@ -107,7 +107,7 @@ _ol_pointer_MsSource_.prototype.cleanup = function(pointerId) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MsSource_.prototype.msPointerDown = function(inEvent) { MsSource.prototype.msPointerDown = function(inEvent) {
this.pointerMap[inEvent.pointerId.toString()] = inEvent; this.pointerMap[inEvent.pointerId.toString()] = inEvent;
const e = this.prepareEvent_(inEvent); const e = this.prepareEvent_(inEvent);
this.dispatcher.down(e, inEvent); this.dispatcher.down(e, inEvent);
@@ -119,7 +119,7 @@ _ol_pointer_MsSource_.prototype.msPointerDown = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MsSource_.prototype.msPointerMove = function(inEvent) { MsSource.prototype.msPointerMove = function(inEvent) {
const e = this.prepareEvent_(inEvent); const e = this.prepareEvent_(inEvent);
this.dispatcher.move(e, inEvent); this.dispatcher.move(e, inEvent);
}; };
@@ -130,7 +130,7 @@ _ol_pointer_MsSource_.prototype.msPointerMove = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MsSource_.prototype.msPointerUp = function(inEvent) { MsSource.prototype.msPointerUp = function(inEvent) {
const e = this.prepareEvent_(inEvent); const e = this.prepareEvent_(inEvent);
this.dispatcher.up(e, inEvent); this.dispatcher.up(e, inEvent);
this.cleanup(inEvent.pointerId); this.cleanup(inEvent.pointerId);
@@ -142,7 +142,7 @@ _ol_pointer_MsSource_.prototype.msPointerUp = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MsSource_.prototype.msPointerOut = function(inEvent) { MsSource.prototype.msPointerOut = function(inEvent) {
const e = this.prepareEvent_(inEvent); const e = this.prepareEvent_(inEvent);
this.dispatcher.leaveOut(e, inEvent); this.dispatcher.leaveOut(e, inEvent);
}; };
@@ -153,7 +153,7 @@ _ol_pointer_MsSource_.prototype.msPointerOut = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MsSource_.prototype.msPointerOver = function(inEvent) { MsSource.prototype.msPointerOver = function(inEvent) {
const e = this.prepareEvent_(inEvent); const e = this.prepareEvent_(inEvent);
this.dispatcher.enterOver(e, inEvent); this.dispatcher.enterOver(e, inEvent);
}; };
@@ -164,7 +164,7 @@ _ol_pointer_MsSource_.prototype.msPointerOver = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MsSource_.prototype.msPointerCancel = function(inEvent) { MsSource.prototype.msPointerCancel = function(inEvent) {
const e = this.prepareEvent_(inEvent); const e = this.prepareEvent_(inEvent);
this.dispatcher.cancel(e, inEvent); this.dispatcher.cancel(e, inEvent);
this.cleanup(inEvent.pointerId); this.cleanup(inEvent.pointerId);
@@ -176,7 +176,7 @@ _ol_pointer_MsSource_.prototype.msPointerCancel = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MsSource_.prototype.msLostPointerCapture = function(inEvent) { MsSource.prototype.msLostPointerCapture = function(inEvent) {
const e = this.dispatcher.makeEvent('lostpointercapture', const e = this.dispatcher.makeEvent('lostpointercapture',
inEvent, inEvent); inEvent, inEvent);
this.dispatcher.dispatchEvent(e); this.dispatcher.dispatchEvent(e);
@@ -188,9 +188,9 @@ _ol_pointer_MsSource_.prototype.msLostPointerCapture = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_MsSource_.prototype.msGotPointerCapture = function(inEvent) { MsSource.prototype.msGotPointerCapture = function(inEvent) {
const e = this.dispatcher.makeEvent('gotpointercapture', const e = this.dispatcher.makeEvent('gotpointercapture',
inEvent, inEvent); inEvent, inEvent);
this.dispatcher.dispatchEvent(e); this.dispatcher.dispatchEvent(e);
}; };
export default _ol_pointer_MsSource_; export default MsSource;
+13 -13
View File
@@ -32,14 +32,14 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import {inherits} from '../index.js'; 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. * @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @constructor * @constructor
* @extends {ol.pointer.EventSource} * @extends {ol.pointer.EventSource}
*/ */
const _ol_pointer_NativeSource_ = function(dispatcher) { const NativeSource = function(dispatcher) {
const mapping = { const mapping = {
'pointerdown': this.pointerDown, 'pointerdown': this.pointerDown,
'pointermove': this.pointerMove, 'pointermove': this.pointerMove,
@@ -50,10 +50,10 @@ const _ol_pointer_NativeSource_ = function(dispatcher) {
'gotpointercapture': this.gotPointerCapture, 'gotpointercapture': this.gotPointerCapture,
'lostpointercapture': this.lostPointerCapture '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. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_NativeSource_.prototype.pointerDown = function(inEvent) { NativeSource.prototype.pointerDown = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent); this.dispatcher.fireNativeEvent(inEvent);
}; };
@@ -71,7 +71,7 @@ _ol_pointer_NativeSource_.prototype.pointerDown = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_NativeSource_.prototype.pointerMove = function(inEvent) { NativeSource.prototype.pointerMove = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent); this.dispatcher.fireNativeEvent(inEvent);
}; };
@@ -81,7 +81,7 @@ _ol_pointer_NativeSource_.prototype.pointerMove = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_NativeSource_.prototype.pointerUp = function(inEvent) { NativeSource.prototype.pointerUp = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent); this.dispatcher.fireNativeEvent(inEvent);
}; };
@@ -91,7 +91,7 @@ _ol_pointer_NativeSource_.prototype.pointerUp = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_NativeSource_.prototype.pointerOut = function(inEvent) { NativeSource.prototype.pointerOut = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent); this.dispatcher.fireNativeEvent(inEvent);
}; };
@@ -101,7 +101,7 @@ _ol_pointer_NativeSource_.prototype.pointerOut = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_NativeSource_.prototype.pointerOver = function(inEvent) { NativeSource.prototype.pointerOver = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent); this.dispatcher.fireNativeEvent(inEvent);
}; };
@@ -111,7 +111,7 @@ _ol_pointer_NativeSource_.prototype.pointerOver = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_NativeSource_.prototype.pointerCancel = function(inEvent) { NativeSource.prototype.pointerCancel = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent); this.dispatcher.fireNativeEvent(inEvent);
}; };
@@ -121,7 +121,7 @@ _ol_pointer_NativeSource_.prototype.pointerCancel = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_NativeSource_.prototype.lostPointerCapture = function(inEvent) { NativeSource.prototype.lostPointerCapture = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent); this.dispatcher.fireNativeEvent(inEvent);
}; };
@@ -131,7 +131,7 @@ _ol_pointer_NativeSource_.prototype.lostPointerCapture = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_NativeSource_.prototype.gotPointerCapture = function(inEvent) { NativeSource.prototype.gotPointerCapture = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent); this.dispatcher.fireNativeEvent(inEvent);
}; };
export default _ol_pointer_NativeSource_; export default NativeSource;
+9 -10
View File
@@ -36,11 +36,11 @@ import _ol_events_ from '../events.js';
import EventTarget from '../events/EventTarget.js'; import EventTarget from '../events/EventTarget.js';
import _ol_has_ from '../has.js'; import _ol_has_ from '../has.js';
import PointerEventType from '../pointer/EventType.js'; import PointerEventType from '../pointer/EventType.js';
import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js'; import MouseSource from '../pointer/MouseSource.js';
import _ol_pointer_MsSource_ from '../pointer/MsSource.js'; import MsSource from '../pointer/MsSource.js';
import _ol_pointer_NativeSource_ from '../pointer/NativeSource.js'; import NativeSource from '../pointer/NativeSource.js';
import PointerEvent from '../pointer/PointerEvent.js'; import PointerEvent from '../pointer/PointerEvent.js';
import _ol_pointer_TouchSource_ from '../pointer/TouchSource.js'; import TouchSource from '../pointer/TouchSource.js';
/** /**
* @constructor * @constructor
@@ -87,16 +87,15 @@ inherits(PointerEventHandler, EventTarget);
*/ */
PointerEventHandler.prototype.registerSources = function() { PointerEventHandler.prototype.registerSources = function() {
if (_ol_has_.POINTER) { if (_ol_has_.POINTER) {
this.registerSource('native', new _ol_pointer_NativeSource_(this)); this.registerSource('native', new NativeSource(this));
} else if (_ol_has_.MSPOINTER) { } else if (_ol_has_.MSPOINTER) {
this.registerSource('ms', new _ol_pointer_MsSource_(this)); this.registerSource('ms', new MsSource(this));
} else { } else {
const mouseSource = new _ol_pointer_MouseSource_(this); const mouseSource = new MouseSource(this);
this.registerSource('mouse', mouseSource); this.registerSource('mouse', mouseSource);
if (_ol_has_.TOUCH) { if (_ol_has_.TOUCH) {
this.registerSource('touch', this.registerSource('touch', new TouchSource(this, mouseSource));
new _ol_pointer_TouchSource_(this, mouseSource));
} }
} }
@@ -389,7 +388,7 @@ PointerEventHandler.prototype.fireNativeEvent = function(event) {
*/ */
PointerEventHandler.prototype.wrapMouseEvent = function(eventType, event) { PointerEventHandler.prototype.wrapMouseEvent = function(eventType, event) {
const pointerEvent = this.makeEvent( const pointerEvent = this.makeEvent(
eventType, _ol_pointer_MouseSource_.prepareEvent(event, this), event); eventType, MouseSource.prepareEvent(event, this), event);
return pointerEvent; return pointerEvent;
}; };
+34 -34
View File
@@ -33,8 +33,8 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import {remove} from '../array.js'; import {remove} from '../array.js';
import _ol_pointer_EventSource_ from '../pointer/EventSource.js'; import EventSource from '../pointer/EventSource.js';
import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js'; import MouseSource from '../pointer/MouseSource.js';
/** /**
* @constructor * @constructor
@@ -42,14 +42,14 @@ import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js';
* @param {ol.pointer.MouseSource} mouseSource Mouse source. * @param {ol.pointer.MouseSource} mouseSource Mouse source.
* @extends {ol.pointer.EventSource} * @extends {ol.pointer.EventSource}
*/ */
const _ol_pointer_TouchSource_ = function(dispatcher, mouseSource) { const TouchSource = function(dispatcher, mouseSource) {
const mapping = { const mapping = {
'touchstart': this.touchstart, 'touchstart': this.touchstart,
'touchmove': this.touchmove, 'touchmove': this.touchmove,
'touchend': this.touchend, 'touchend': this.touchend,
'touchcancel': this.touchcancel 'touchcancel': this.touchcancel
}; };
_ol_pointer_EventSource_.call(this, dispatcher, mapping); EventSource.call(this, dispatcher, mapping);
/** /**
* @const * @const
@@ -82,7 +82,7 @@ const _ol_pointer_TouchSource_ = function(dispatcher, mouseSource) {
this.resetId_ = undefined; 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 * @const
* @type {number} * @type {number}
*/ */
_ol_pointer_TouchSource_.DEDUP_TIMEOUT = 2500; TouchSource.DEDUP_TIMEOUT = 2500;
/** /**
* @const * @const
* @type {number} * @type {number}
*/ */
_ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT = 200; TouchSource.CLICK_COUNT_TIMEOUT = 200;
/** /**
* @const * @const
* @type {string} * @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. * @param {Touch} inTouch The in touch.
* @return {boolean} True, if this is the primary 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; return this.firstTouchId_ === inTouch.identifier;
}; };
@@ -123,10 +123,10 @@ _ol_pointer_TouchSource_.prototype.isPrimaryTouch_ = function(inTouch) {
* @param {Touch} inTouch The in touch. * @param {Touch} inTouch The in touch.
* @private * @private
*/ */
_ol_pointer_TouchSource_.prototype.setPrimaryTouch_ = function(inTouch) { TouchSource.prototype.setPrimaryTouch_ = function(inTouch) {
const count = Object.keys(this.pointerMap).length; const count = Object.keys(this.pointerMap).length;
if (count === 0 || (count === 1 && 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.firstTouchId_ = inTouch.identifier;
this.cancelResetClickCount_(); this.cancelResetClickCount_();
} }
@@ -137,7 +137,7 @@ _ol_pointer_TouchSource_.prototype.setPrimaryTouch_ = function(inTouch) {
* @private * @private
* @param {Object} inPointer The in pointer object. * @param {Object} inPointer The in pointer object.
*/ */
_ol_pointer_TouchSource_.prototype.removePrimaryPointer_ = function(inPointer) { TouchSource.prototype.removePrimaryPointer_ = function(inPointer) {
if (inPointer.isPrimary) { if (inPointer.isPrimary) {
this.firstTouchId_ = undefined; this.firstTouchId_ = undefined;
this.resetClickCount_(); this.resetClickCount_();
@@ -148,17 +148,17 @@ _ol_pointer_TouchSource_.prototype.removePrimaryPointer_ = function(inPointer) {
/** /**
* @private * @private
*/ */
_ol_pointer_TouchSource_.prototype.resetClickCount_ = function() { TouchSource.prototype.resetClickCount_ = function() {
this.resetId_ = setTimeout( this.resetId_ = setTimeout(
this.resetClickCountHandler_.bind(this), this.resetClickCountHandler_.bind(this),
_ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT); TouchSource.CLICK_COUNT_TIMEOUT);
}; };
/** /**
* @private * @private
*/ */
_ol_pointer_TouchSource_.prototype.resetClickCountHandler_ = function() { TouchSource.prototype.resetClickCountHandler_ = function() {
this.clickCount_ = 0; this.clickCount_ = 0;
this.resetId_ = undefined; this.resetId_ = undefined;
}; };
@@ -167,7 +167,7 @@ _ol_pointer_TouchSource_.prototype.resetClickCountHandler_ = function() {
/** /**
* @private * @private
*/ */
_ol_pointer_TouchSource_.prototype.cancelResetClickCount_ = function() { TouchSource.prototype.cancelResetClickCount_ = function() {
if (this.resetId_ !== undefined) { if (this.resetId_ !== undefined) {
clearTimeout(this.resetId_); clearTimeout(this.resetId_);
} }
@@ -180,7 +180,7 @@ _ol_pointer_TouchSource_.prototype.cancelResetClickCount_ = function() {
* @param {Touch} inTouch Touch event * @param {Touch} inTouch Touch event
* @return {Object} A pointer object. * @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); const e = this.dispatcher.cloneEvent(browserEvent, inTouch);
// Spec specifies that pointerId 1 is reserved for Mouse. // Spec specifies that pointerId 1 is reserved for Mouse.
// Touch identifiers can start at 0. // 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.height = inTouch.webkitRadiusY || inTouch.radiusY || 0;
e.pressure = inTouch.webkitForce || inTouch.force || 0.5; e.pressure = inTouch.webkitForce || inTouch.force || 0.5;
e.isPrimary = this.isPrimaryTouch_(inTouch); 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 // make sure that the properties that are different for
// each `Touch` object are not copied from the BrowserEvent object // 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 {Event} inEvent Touch event
* @param {function(Event, Object)} inFunction In function. * @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( const touches = Array.prototype.slice.call(
inEvent.changedTouches); inEvent.changedTouches);
const count = touches.length; const count = touches.length;
@@ -238,7 +238,7 @@ _ol_pointer_TouchSource_.prototype.processTouches_ = function(inEvent, inFunctio
* @param {number} searchId Search identifier. * @param {number} searchId Search identifier.
* @return {boolean} True, if the `Touch` with the given id is in the list. * @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; const l = touchList.length;
let touch; let touch;
for (let i = 0; i < l; i++) { for (let i = 0; i < l; i++) {
@@ -262,7 +262,7 @@ _ol_pointer_TouchSource_.prototype.findTouch_ = function(touchList, searchId) {
* @private * @private
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_TouchSource_.prototype.vacuumTouches_ = function(inEvent) { TouchSource.prototype.vacuumTouches_ = function(inEvent) {
const touchList = inEvent.touches; const touchList = inEvent.touches;
// pointerMap.getCount() should be < touchList.length here, // pointerMap.getCount() should be < touchList.length here,
// as the touchstart has not been processed yet. // 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. // Never remove pointerId == 1, which is mouse.
// Touch identifiers are 2 smaller than their pointerId, which is the // Touch identifiers are 2 smaller than their pointerId, which is the
// index in pointermap. // index in pointermap.
if (key != _ol_pointer_MouseSource_.POINTER_ID && if (key != MouseSource.POINTER_ID &&
!this.findTouch_(touchList, key - 2)) { !this.findTouch_(touchList, key - 2)) {
d.push(value.out); d.push(value.out);
} }
@@ -295,7 +295,7 @@ _ol_pointer_TouchSource_.prototype.vacuumTouches_ = function(inEvent) {
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_TouchSource_.prototype.touchstart = function(inEvent) { TouchSource.prototype.touchstart = function(inEvent) {
this.vacuumTouches_(inEvent); this.vacuumTouches_(inEvent);
this.setPrimaryTouch_(inEvent.changedTouches[0]); this.setPrimaryTouch_(inEvent.changedTouches[0]);
this.dedupSynthMouse_(inEvent); this.dedupSynthMouse_(inEvent);
@@ -309,7 +309,7 @@ _ol_pointer_TouchSource_.prototype.touchstart = function(inEvent) {
* @param {Event} browserEvent The event. * @param {Event} browserEvent The event.
* @param {Object} inPointer The in pointer object. * @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] = { this.pointerMap[inPointer.pointerId] = {
target: inPointer.target, target: inPointer.target,
out: inPointer, out: inPointer,
@@ -326,7 +326,7 @@ _ol_pointer_TouchSource_.prototype.overDown_ = function(browserEvent, inPointer)
* *
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_TouchSource_.prototype.touchmove = function(inEvent) { TouchSource.prototype.touchmove = function(inEvent) {
inEvent.preventDefault(); inEvent.preventDefault();
this.processTouches_(inEvent, this.moveOverOut_); this.processTouches_(inEvent, this.moveOverOut_);
}; };
@@ -337,7 +337,7 @@ _ol_pointer_TouchSource_.prototype.touchmove = function(inEvent) {
* @param {Event} browserEvent The event. * @param {Event} browserEvent The event.
* @param {Object} inPointer The in pointer. * @param {Object} inPointer The in pointer.
*/ */
_ol_pointer_TouchSource_.prototype.moveOverOut_ = function(browserEvent, inPointer) { TouchSource.prototype.moveOverOut_ = function(browserEvent, inPointer) {
const event = inPointer; const event = inPointer;
const pointer = this.pointerMap[event.pointerId]; const pointer = this.pointerMap[event.pointerId];
// a finger drifted off the screen, ignore it // 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. * @param {Event} inEvent The event.
*/ */
_ol_pointer_TouchSource_.prototype.touchend = function(inEvent) { TouchSource.prototype.touchend = function(inEvent) {
this.dedupSynthMouse_(inEvent); this.dedupSynthMouse_(inEvent);
this.processTouches_(inEvent, this.upOut_); this.processTouches_(inEvent, this.upOut_);
}; };
@@ -384,7 +384,7 @@ _ol_pointer_TouchSource_.prototype.touchend = function(inEvent) {
* @param {Event} browserEvent An event. * @param {Event} browserEvent An event.
* @param {Object} inPointer The inPointer object. * @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.up(inPointer, browserEvent);
this.dispatcher.out(inPointer, browserEvent); this.dispatcher.out(inPointer, browserEvent);
this.dispatcher.leave(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. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_TouchSource_.prototype.touchcancel = function(inEvent) { TouchSource.prototype.touchcancel = function(inEvent) {
this.processTouches_(inEvent, this.cancelOut_); this.processTouches_(inEvent, this.cancelOut_);
}; };
@@ -408,7 +408,7 @@ _ol_pointer_TouchSource_.prototype.touchcancel = function(inEvent) {
* @param {Event} browserEvent The event. * @param {Event} browserEvent The event.
* @param {Object} inPointer The in pointer. * @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.cancel(inPointer, browserEvent);
this.dispatcher.out(inPointer, browserEvent); this.dispatcher.out(inPointer, browserEvent);
this.dispatcher.leave(inPointer, browserEvent); this.dispatcher.leave(inPointer, browserEvent);
@@ -420,7 +420,7 @@ _ol_pointer_TouchSource_.prototype.cancelOut_ = function(browserEvent, inPointer
* @private * @private
* @param {Object} inPointer The inPointer object. * @param {Object} inPointer The inPointer object.
*/ */
_ol_pointer_TouchSource_.prototype.cleanUpPointer_ = function(inPointer) { TouchSource.prototype.cleanUpPointer_ = function(inPointer) {
delete this.pointerMap[inPointer.pointerId]; delete this.pointerMap[inPointer.pointerId];
this.removePrimaryPointer_(inPointer); this.removePrimaryPointer_(inPointer);
}; };
@@ -432,7 +432,7 @@ _ol_pointer_TouchSource_.prototype.cleanUpPointer_ = function(inPointer) {
* @private * @private
* @param {Event} inEvent The in event. * @param {Event} inEvent The in event.
*/ */
_ol_pointer_TouchSource_.prototype.dedupSynthMouse_ = function(inEvent) { TouchSource.prototype.dedupSynthMouse_ = function(inEvent) {
const lts = this.mouseSource.lastTouches; const lts = this.mouseSource.lastTouches;
const t = inEvent.changedTouches[0]; const t = inEvent.changedTouches[0];
// only the primary finger will synth mouse events // only the primary finger will synth mouse events
@@ -444,7 +444,7 @@ _ol_pointer_TouchSource_.prototype.dedupSynthMouse_ = function(inEvent) {
setTimeout(function() { setTimeout(function() {
// remove touch after timeout // remove touch after timeout
remove(lts, lt); remove(lts, lt);
}, _ol_pointer_TouchSource_.DEDUP_TIMEOUT); }, TouchSource.DEDUP_TIMEOUT);
} }
}; };
export default _ol_pointer_TouchSource_; export default TouchSource;
+2 -2
View File
@@ -2,7 +2,7 @@ import _ol_events_ from '../../../../src/ol/events.js';
import EventTarget from '../../../../src/ol/events/EventTarget.js'; import EventTarget from '../../../../src/ol/events/EventTarget.js';
import _ol_has_ from '../../../../src/ol/has.js'; import _ol_has_ from '../../../../src/ol/has.js';
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.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() { describe('ol.pointer.MouseSource', function() {
@@ -53,7 +53,7 @@ describe('ol.pointer.MouseSource', function() {
it('dispatches real mouse events after timeout', function() { it('dispatches real mouse events after timeout', function() {
// set the timeout to a lower value, to speed up the tests // 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); _ol_events_.listen(handler, 'pointerdown', eventSpy);
@@ -1,7 +1,7 @@
import _ol_events_ from '../../../../src/ol/events.js'; import _ol_events_ from '../../../../src/ol/events.js';
import EventTarget from '../../../../src/ol/events/EventTarget.js'; import EventTarget from '../../../../src/ol/events/EventTarget.js';
import _ol_has_ from '../../../../src/ol/has.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 PointerEvent from '../../../../src/ol/pointer/PointerEvent.js';
import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.js'; import PointerEventHandler from '../../../../src/ol/pointer/PointerEventHandler.js';
@@ -30,7 +30,7 @@ describe('ol.pointer.PointerEventHandler', function() {
describe('constructor', function() { describe('constructor', function() {
it('registers a least one event source', function() { it('registers a least one event source', function() {
expect(handler.eventSourceList_.length).to.be.greaterThan(0); 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);
}); });
}); });