Rename _ol_pointer_MouseSource_ to MouseSource
This commit is contained in:
@@ -39,7 +39,7 @@ import EventSource from '../pointer/EventSource.js';
|
||||
* @constructor
|
||||
* @extends {ol.pointer.EventSource}
|
||||
*/
|
||||
const _ol_pointer_MouseSource_ = function(dispatcher) {
|
||||
const MouseSource = function(dispatcher) {
|
||||
const mapping = {
|
||||
'mousedown': this.mousedown,
|
||||
'mousemove': this.mousemove,
|
||||
@@ -62,21 +62,21 @@ const _ol_pointer_MouseSource_ = function(dispatcher) {
|
||||
this.lastTouches = [];
|
||||
};
|
||||
|
||||
inherits(_ol_pointer_MouseSource_, 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;
|
||||
|
||||
Reference in New Issue
Block a user