Transformed

This commit is contained in:
Tim Schaub
2017-12-11 16:29:33 -07:00
parent 1cdb6a66f0
commit 7f47883c48
737 changed files with 22216 additions and 21609 deletions

View File

@@ -1,13 +1,13 @@
goog.provide('ol.pointer.EventSource');
/**
* @module ol/pointer/EventSource
*/
/**
* @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @param {!Object.<string, function(Event)>} mapping Event
* mapping.
* @constructor
*/
ol.pointer.EventSource = function(dispatcher, mapping) {
var _ol_pointer_EventSource_ = function(dispatcher, mapping) {
/**
* @type {ol.pointer.PointerEventHandler}
*/
@@ -26,7 +26,7 @@ ol.pointer.EventSource = function(dispatcher, mapping) {
* List of events supported by this source.
* @return {Array.<string>} Event names
*/
ol.pointer.EventSource.prototype.getEvents = function() {
_ol_pointer_EventSource_.prototype.getEvents = function() {
return Object.keys(this.mapping_);
};
@@ -36,6 +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) {
_ol_pointer_EventSource_.prototype.getHandlerForEvent = function(eventType) {
return this.mapping_[eventType];
};
export default _ol_pointer_EventSource_;

View File

@@ -1,11 +1,11 @@
goog.provide('ol.pointer.EventType');
/**
* @module ol/pointer/EventType
*/
/**
* Constants for event names.
* @enum {string}
*/
ol.pointer.EventType = {
var _ol_pointer_EventType_ = {
POINTERMOVE: 'pointermove',
POINTERDOWN: 'pointerdown',
POINTERUP: 'pointerup',
@@ -15,3 +15,5 @@ ol.pointer.EventType = {
POINTERLEAVE: 'pointerleave',
POINTERCANCEL: 'pointercancel'
};
export default _ol_pointer_EventType_;

View File

@@ -1,3 +1,6 @@
/**
* @module ol/pointer/MouseSource
*/
// Based on https://github.com/Polymer/PointerEvents
// Copyright (c) 2013 The Polymer Authors. All rights reserved.
@@ -28,18 +31,15 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
goog.provide('ol.pointer.MouseSource');
goog.require('ol');
goog.require('ol.pointer.EventSource');
import _ol_ from '../index.js';
import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
/**
* @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @constructor
* @extends {ol.pointer.EventSource}
*/
ol.pointer.MouseSource = function(dispatcher) {
var _ol_pointer_MouseSource_ = function(dispatcher) {
var mapping = {
'mousedown': this.mousedown,
'mousemove': this.mousemove,
@@ -47,7 +47,7 @@ ol.pointer.MouseSource = function(dispatcher) {
'mouseover': this.mouseover,
'mouseout': this.mouseout
};
ol.pointer.EventSource.call(this, dispatcher, mapping);
_ol_pointer_EventSource_.call(this, dispatcher, mapping);
/**
* @const
@@ -61,21 +61,22 @@ ol.pointer.MouseSource = function(dispatcher) {
*/
this.lastTouches = [];
};
ol.inherits(ol.pointer.MouseSource, ol.pointer.EventSource);
_ol_.inherits(_ol_pointer_MouseSource_, _ol_pointer_EventSource_);
/**
* @const
* @type {number}
*/
ol.pointer.MouseSource.POINTER_ID = 1;
_ol_pointer_MouseSource_.POINTER_ID = 1;
/**
* @const
* @type {string}
*/
ol.pointer.MouseSource.POINTER_TYPE = 'mouse';
_ol_pointer_MouseSource_.POINTER_TYPE = 'mouse';
/**
@@ -84,7 +85,7 @@ ol.pointer.MouseSource.POINTER_TYPE = 'mouse';
* @const
* @type {number}
*/
ol.pointer.MouseSource.DEDUP_DIST = 25;
_ol_pointer_MouseSource_.DEDUP_DIST = 25;
/**
@@ -111,14 +112,14 @@ 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) {
_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++) {
// simulated mouse events will be swallowed near a primary touchend
var dx = Math.abs(x - t[0]), dy = Math.abs(y - t[1]);
if (dx <= ol.pointer.MouseSource.DEDUP_DIST &&
dy <= ol.pointer.MouseSource.DEDUP_DIST) {
if (dx <= _ol_pointer_MouseSource_.DEDUP_DIST &&
dy <= _ol_pointer_MouseSource_.DEDUP_DIST) {
return true;
}
}
@@ -134,7 +135,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) {
_ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) {
var e = dispatcher.cloneEvent(inEvent, inEvent);
// forward mouse preventDefault
@@ -144,9 +145,9 @@ ol.pointer.MouseSource.prepareEvent = function(inEvent, dispatcher) {
pd();
};
e.pointerId = ol.pointer.MouseSource.POINTER_ID;
e.pointerId = _ol_pointer_MouseSource_.POINTER_ID;
e.isPrimary = true;
e.pointerType = ol.pointer.MouseSource.POINTER_TYPE;
e.pointerType = _ol_pointer_MouseSource_.POINTER_TYPE;
return e;
};
@@ -157,15 +158,15 @@ ol.pointer.MouseSource.prepareEvent = function(inEvent, dispatcher) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MouseSource.prototype.mousedown = function(inEvent) {
_ol_pointer_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 (_ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap) {
this.cancel(inEvent);
}
var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher);
this.pointerMap[ol.pointer.MouseSource.POINTER_ID.toString()] = inEvent;
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()] = inEvent;
this.dispatcher.down(e, inEvent);
}
};
@@ -176,9 +177,9 @@ ol.pointer.MouseSource.prototype.mousedown = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MouseSource.prototype.mousemove = function(inEvent) {
_ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher);
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.move(e, inEvent);
}
};
@@ -189,12 +190,12 @@ ol.pointer.MouseSource.prototype.mousemove = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MouseSource.prototype.mouseup = function(inEvent) {
_ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
var p = this.pointerMap[ol.pointer.MouseSource.POINTER_ID.toString()];
var p = this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()];
if (p && p.button === inEvent.button) {
var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher);
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.up(e, inEvent);
this.cleanupMouse();
}
@@ -207,9 +208,9 @@ ol.pointer.MouseSource.prototype.mouseup = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MouseSource.prototype.mouseover = function(inEvent) {
_ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher);
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.enterOver(e, inEvent);
}
};
@@ -220,9 +221,9 @@ ol.pointer.MouseSource.prototype.mouseover = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MouseSource.prototype.mouseout = function(inEvent) {
_ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
var e = ol.pointer.MouseSource.prepareEvent(inEvent, this.dispatcher);
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.leaveOut(e, inEvent);
}
};
@@ -233,8 +234,8 @@ 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);
_ol_pointer_MouseSource_.prototype.cancel = function(inEvent) {
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.cancel(e, inEvent);
this.cleanupMouse();
};
@@ -243,6 +244,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()];
_ol_pointer_MouseSource_.prototype.cleanupMouse = function() {
delete this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()];
};
export default _ol_pointer_MouseSource_;

View File

@@ -1,3 +1,6 @@
/**
* @module ol/pointer/MsSource
*/
// Based on https://github.com/Polymer/PointerEvents
// Copyright (c) 2013 The Polymer Authors. All rights reserved.
@@ -28,18 +31,15 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
goog.provide('ol.pointer.MsSource');
goog.require('ol');
goog.require('ol.pointer.EventSource');
import _ol_ from '../index.js';
import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
/**
* @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @constructor
* @extends {ol.pointer.EventSource}
*/
ol.pointer.MsSource = function(dispatcher) {
var _ol_pointer_MsSource_ = function(dispatcher) {
var mapping = {
'MSPointerDown': this.msPointerDown,
'MSPointerMove': this.msPointerMove,
@@ -50,7 +50,7 @@ ol.pointer.MsSource = function(dispatcher) {
'MSGotPointerCapture': this.msGotPointerCapture,
'MSLostPointerCapture': this.msLostPointerCapture
};
ol.pointer.EventSource.call(this, dispatcher, mapping);
_ol_pointer_EventSource_.call(this, dispatcher, mapping);
/**
* @const
@@ -70,7 +70,8 @@ ol.pointer.MsSource = function(dispatcher) {
'mouse'
];
};
ol.inherits(ol.pointer.MsSource, ol.pointer.EventSource);
_ol_.inherits(_ol_pointer_MsSource_, _ol_pointer_EventSource_);
/**
@@ -81,7 +82,7 @@ ol.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) {
_ol_pointer_MsSource_.prototype.prepareEvent_ = function(inEvent) {
var e = inEvent;
if (typeof inEvent.pointerType === 'number') {
e = this.dispatcher.cloneEvent(inEvent, inEvent);
@@ -96,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) {
_ol_pointer_MsSource_.prototype.cleanup = function(pointerId) {
delete this.pointerMap[pointerId.toString()];
};
@@ -106,7 +107,7 @@ ol.pointer.MsSource.prototype.cleanup = function(pointerId) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MsSource.prototype.msPointerDown = function(inEvent) {
_ol_pointer_MsSource_.prototype.msPointerDown = function(inEvent) {
this.pointerMap[inEvent.pointerId.toString()] = inEvent;
var e = this.prepareEvent_(inEvent);
this.dispatcher.down(e, inEvent);
@@ -118,7 +119,7 @@ ol.pointer.MsSource.prototype.msPointerDown = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MsSource.prototype.msPointerMove = function(inEvent) {
_ol_pointer_MsSource_.prototype.msPointerMove = function(inEvent) {
var e = this.prepareEvent_(inEvent);
this.dispatcher.move(e, inEvent);
};
@@ -129,7 +130,7 @@ ol.pointer.MsSource.prototype.msPointerMove = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MsSource.prototype.msPointerUp = function(inEvent) {
_ol_pointer_MsSource_.prototype.msPointerUp = function(inEvent) {
var e = this.prepareEvent_(inEvent);
this.dispatcher.up(e, inEvent);
this.cleanup(inEvent.pointerId);
@@ -141,7 +142,7 @@ ol.pointer.MsSource.prototype.msPointerUp = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MsSource.prototype.msPointerOut = function(inEvent) {
_ol_pointer_MsSource_.prototype.msPointerOut = function(inEvent) {
var e = this.prepareEvent_(inEvent);
this.dispatcher.leaveOut(e, inEvent);
};
@@ -152,7 +153,7 @@ ol.pointer.MsSource.prototype.msPointerOut = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MsSource.prototype.msPointerOver = function(inEvent) {
_ol_pointer_MsSource_.prototype.msPointerOver = function(inEvent) {
var e = this.prepareEvent_(inEvent);
this.dispatcher.enterOver(e, inEvent);
};
@@ -163,7 +164,7 @@ ol.pointer.MsSource.prototype.msPointerOver = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MsSource.prototype.msPointerCancel = function(inEvent) {
_ol_pointer_MsSource_.prototype.msPointerCancel = function(inEvent) {
var e = this.prepareEvent_(inEvent);
this.dispatcher.cancel(e, inEvent);
this.cleanup(inEvent.pointerId);
@@ -175,7 +176,7 @@ ol.pointer.MsSource.prototype.msPointerCancel = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MsSource.prototype.msLostPointerCapture = function(inEvent) {
_ol_pointer_MsSource_.prototype.msLostPointerCapture = function(inEvent) {
var e = this.dispatcher.makeEvent('lostpointercapture',
inEvent, inEvent);
this.dispatcher.dispatchEvent(e);
@@ -187,8 +188,9 @@ ol.pointer.MsSource.prototype.msLostPointerCapture = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.MsSource.prototype.msGotPointerCapture = function(inEvent) {
_ol_pointer_MsSource_.prototype.msGotPointerCapture = function(inEvent) {
var e = this.dispatcher.makeEvent('gotpointercapture',
inEvent, inEvent);
this.dispatcher.dispatchEvent(e);
};
export default _ol_pointer_MsSource_;

View File

@@ -1,3 +1,6 @@
/**
* @module ol/pointer/NativeSource
*/
// Based on https://github.com/Polymer/PointerEvents
// Copyright (c) 2013 The Polymer Authors. All rights reserved.
@@ -28,18 +31,15 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
goog.provide('ol.pointer.NativeSource');
goog.require('ol');
goog.require('ol.pointer.EventSource');
import _ol_ from '../index.js';
import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
/**
* @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
* @constructor
* @extends {ol.pointer.EventSource}
*/
ol.pointer.NativeSource = function(dispatcher) {
var _ol_pointer_NativeSource_ = function(dispatcher) {
var mapping = {
'pointerdown': this.pointerDown,
'pointermove': this.pointerMove,
@@ -50,9 +50,10 @@ ol.pointer.NativeSource = function(dispatcher) {
'gotpointercapture': this.gotPointerCapture,
'lostpointercapture': this.lostPointerCapture
};
ol.pointer.EventSource.call(this, dispatcher, mapping);
_ol_pointer_EventSource_.call(this, dispatcher, mapping);
};
ol.inherits(ol.pointer.NativeSource, ol.pointer.EventSource);
_ol_.inherits(_ol_pointer_NativeSource_, _ol_pointer_EventSource_);
/**
@@ -60,7 +61,7 @@ ol.inherits(ol.pointer.NativeSource, ol.pointer.EventSource);
*
* @param {Event} inEvent The in event.
*/
ol.pointer.NativeSource.prototype.pointerDown = function(inEvent) {
_ol_pointer_NativeSource_.prototype.pointerDown = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -70,7 +71,7 @@ ol.pointer.NativeSource.prototype.pointerDown = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.NativeSource.prototype.pointerMove = function(inEvent) {
_ol_pointer_NativeSource_.prototype.pointerMove = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -80,7 +81,7 @@ ol.pointer.NativeSource.prototype.pointerMove = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.NativeSource.prototype.pointerUp = function(inEvent) {
_ol_pointer_NativeSource_.prototype.pointerUp = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -90,7 +91,7 @@ ol.pointer.NativeSource.prototype.pointerUp = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.NativeSource.prototype.pointerOut = function(inEvent) {
_ol_pointer_NativeSource_.prototype.pointerOut = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -100,7 +101,7 @@ ol.pointer.NativeSource.prototype.pointerOut = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.NativeSource.prototype.pointerOver = function(inEvent) {
_ol_pointer_NativeSource_.prototype.pointerOver = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -110,7 +111,7 @@ ol.pointer.NativeSource.prototype.pointerOver = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.NativeSource.prototype.pointerCancel = function(inEvent) {
_ol_pointer_NativeSource_.prototype.pointerCancel = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -120,7 +121,7 @@ ol.pointer.NativeSource.prototype.pointerCancel = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.NativeSource.prototype.lostPointerCapture = function(inEvent) {
_ol_pointer_NativeSource_.prototype.lostPointerCapture = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
@@ -130,6 +131,7 @@ ol.pointer.NativeSource.prototype.lostPointerCapture = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.NativeSource.prototype.gotPointerCapture = function(inEvent) {
_ol_pointer_NativeSource_.prototype.gotPointerCapture = function(inEvent) {
this.dispatcher.fireNativeEvent(inEvent);
};
export default _ol_pointer_NativeSource_;

View File

@@ -1,3 +1,6 @@
/**
* @module ol/pointer/PointerEvent
*/
// Based on https://github.com/Polymer/PointerEvents
// Copyright (c) 2013 The Polymer Authors. All rights reserved.
@@ -28,12 +31,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
goog.provide('ol.pointer.PointerEvent');
goog.require('ol');
goog.require('ol.events.Event');
import _ol_ from '../index.js';
import _ol_events_Event_ from '../events/Event.js';
/**
* A class for pointer events.
@@ -48,8 +47,8 @@ goog.require('ol.events.Event');
* @param {Object.<string, ?>=} opt_eventDict An optional dictionary of
* initial event properties.
*/
ol.pointer.PointerEvent = function(type, originalEvent, opt_eventDict) {
ol.events.Event.call(this, type);
var _ol_pointer_PointerEvent_ = function(type, originalEvent, opt_eventDict) {
_ol_events_Event_.call(this, type);
/**
* @const
@@ -192,7 +191,8 @@ ol.pointer.PointerEvent = function(type, originalEvent, opt_eventDict) {
};
}
};
ol.inherits(ol.pointer.PointerEvent, ol.events.Event);
_ol_.inherits(_ol_pointer_PointerEvent_, _ol_events_Event_);
/**
@@ -200,7 +200,7 @@ ol.inherits(ol.pointer.PointerEvent, ol.events.Event);
* @param {Object.<string, ?>} eventDict The event dictionary.
* @return {number} Button indicator.
*/
ol.pointer.PointerEvent.prototype.getButtons_ = function(eventDict) {
_ol_pointer_PointerEvent_.prototype.getButtons_ = function(eventDict) {
// According to the w3c spec,
// http://www.w3.org/TR/DOM-Level-3-Events/#events-MouseEvent-button
// MouseEvent.button == 0 can mean either no mouse button depressed, or the
@@ -223,7 +223,7 @@ ol.pointer.PointerEvent.prototype.getButtons_ = function(eventDict) {
//
// This is fixed with DOM Level 4's use of buttons
var buttons;
if (eventDict.buttons || ol.pointer.PointerEvent.HAS_BUTTONS) {
if (eventDict.buttons || _ol_pointer_PointerEvent_.HAS_BUTTONS) {
buttons = eventDict.buttons;
} else {
switch (eventDict.which) {
@@ -243,7 +243,7 @@ ol.pointer.PointerEvent.prototype.getButtons_ = function(eventDict) {
* @param {number} buttons Button indicator.
* @return {number} The pressure.
*/
ol.pointer.PointerEvent.prototype.getPressure_ = function(eventDict, buttons) {
_ol_pointer_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;
@@ -260,7 +260,7 @@ ol.pointer.PointerEvent.prototype.getPressure_ = function(eventDict, buttons) {
* Is the `buttons` property supported?
* @type {boolean}
*/
ol.pointer.PointerEvent.HAS_BUTTONS = false;
_ol_pointer_PointerEvent_.HAS_BUTTONS = false;
/**
@@ -269,8 +269,9 @@ ol.pointer.PointerEvent.HAS_BUTTONS = false;
(function() {
try {
var ev = new MouseEvent('click', {buttons: 1});
ol.pointer.PointerEvent.HAS_BUTTONS = ev.buttons === 1;
_ol_pointer_PointerEvent_.HAS_BUTTONS = ev.buttons === 1;
} catch (e) {
// pass
}
})();
export default _ol_pointer_PointerEvent_;

View File

@@ -1,3 +1,6 @@
/**
* @module ol/pointer/PointerEventHandler
*/
// Based on https://github.com/Polymer/PointerEvents
// Copyright (c) 2013 The Polymer Authors. All rights reserved.
@@ -28,28 +31,24 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
goog.provide('ol.pointer.PointerEventHandler');
goog.require('ol');
goog.require('ol.events');
goog.require('ol.events.EventTarget');
goog.require('ol.has');
goog.require('ol.pointer.EventType');
goog.require('ol.pointer.MouseSource');
goog.require('ol.pointer.MsSource');
goog.require('ol.pointer.NativeSource');
goog.require('ol.pointer.PointerEvent');
goog.require('ol.pointer.TouchSource');
import _ol_ from '../index.js';
import _ol_events_ from '../events.js';
import _ol_events_EventTarget_ from '../events/EventTarget.js';
import _ol_has_ from '../has.js';
import _ol_pointer_EventType_ 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 _ol_pointer_PointerEvent_ from '../pointer/PointerEvent.js';
import _ol_pointer_TouchSource_ from '../pointer/TouchSource.js';
/**
* @constructor
* @extends {ol.events.EventTarget}
* @param {Element|HTMLDocument} element Viewport element.
*/
ol.pointer.PointerEventHandler = function(element) {
ol.events.EventTarget.call(this);
var _ol_pointer_PointerEventHandler_ = function(element) {
_ol_events_EventTarget_.call(this);
/**
* @const
@@ -78,25 +77,26 @@ ol.pointer.PointerEventHandler = function(element) {
this.registerSources();
};
ol.inherits(ol.pointer.PointerEventHandler, ol.events.EventTarget);
_ol_.inherits(_ol_pointer_PointerEventHandler_, _ol_events_EventTarget_);
/**
* Set up the event sources (mouse, touch and native pointers)
* that generate pointer events.
*/
ol.pointer.PointerEventHandler.prototype.registerSources = function() {
if (ol.has.POINTER) {
this.registerSource('native', new ol.pointer.NativeSource(this));
} else if (ol.has.MSPOINTER) {
this.registerSource('ms', new ol.pointer.MsSource(this));
_ol_pointer_PointerEventHandler_.prototype.registerSources = function() {
if (_ol_has_.POINTER) {
this.registerSource('native', new _ol_pointer_NativeSource_(this));
} else if (_ol_has_.MSPOINTER) {
this.registerSource('ms', new _ol_pointer_MsSource_(this));
} else {
var mouseSource = new ol.pointer.MouseSource(this);
var mouseSource = new _ol_pointer_MouseSource_(this);
this.registerSource('mouse', mouseSource);
if (ol.has.TOUCH) {
if (_ol_has_.TOUCH) {
this.registerSource('touch',
new ol.pointer.TouchSource(this, mouseSource));
new _ol_pointer_TouchSource_(this, mouseSource));
}
}
@@ -111,7 +111,7 @@ ol.pointer.PointerEventHandler.prototype.registerSources = function() {
* @param {string} name A name for the event source
* @param {ol.pointer.EventSource} source The source event.
*/
ol.pointer.PointerEventHandler.prototype.registerSource = function(name, source) {
_ol_pointer_PointerEventHandler_.prototype.registerSource = function(name, source) {
var s = source;
var newEvents = s.getEvents();
@@ -132,7 +132,7 @@ ol.pointer.PointerEventHandler.prototype.registerSource = function(name, source)
* Set up the events for all registered event sources.
* @private
*/
ol.pointer.PointerEventHandler.prototype.register_ = function() {
_ol_pointer_PointerEventHandler_.prototype.register_ = function() {
var l = this.eventSourceList_.length;
var eventSource;
for (var i = 0; i < l; i++) {
@@ -146,7 +146,7 @@ ol.pointer.PointerEventHandler.prototype.register_ = function() {
* Remove all registered events.
* @private
*/
ol.pointer.PointerEventHandler.prototype.unregister_ = function() {
_ol_pointer_PointerEventHandler_.prototype.unregister_ = function() {
var l = this.eventSourceList_.length;
var eventSource;
for (var i = 0; i < l; i++) {
@@ -161,7 +161,7 @@ ol.pointer.PointerEventHandler.prototype.unregister_ = function() {
* @private
* @param {Event} inEvent Browser event.
*/
ol.pointer.PointerEventHandler.prototype.eventHandler_ = function(inEvent) {
_ol_pointer_PointerEventHandler_.prototype.eventHandler_ = function(inEvent) {
var type = inEvent.type;
var handler = this.eventMap_[type];
if (handler) {
@@ -175,9 +175,9 @@ ol.pointer.PointerEventHandler.prototype.eventHandler_ = function(inEvent) {
* @private
* @param {Array.<string>} events List of events.
*/
ol.pointer.PointerEventHandler.prototype.addEvents_ = function(events) {
_ol_pointer_PointerEventHandler_.prototype.addEvents_ = function(events) {
events.forEach(function(eventName) {
ol.events.listen(this.element_, eventName, this.eventHandler_, this);
_ol_events_.listen(this.element_, eventName, this.eventHandler_, this);
}, this);
};
@@ -187,9 +187,9 @@ ol.pointer.PointerEventHandler.prototype.addEvents_ = function(events) {
* @private
* @param {Array.<string>} events List of events.
*/
ol.pointer.PointerEventHandler.prototype.removeEvents_ = function(events) {
_ol_pointer_PointerEventHandler_.prototype.removeEvents_ = function(events) {
events.forEach(function(e) {
ol.events.unlisten(this.element_, e, this.eventHandler_, this);
_ol_events_.unlisten(this.element_, e, this.eventHandler_, this);
}, this);
};
@@ -203,11 +203,11 @@ ol.pointer.PointerEventHandler.prototype.removeEvents_ = function(events) {
* @return {Object} An object containing shallow copies of
* `inEvent`'s properties.
*/
ol.pointer.PointerEventHandler.prototype.cloneEvent = function(event, inEvent) {
_ol_pointer_PointerEventHandler_.prototype.cloneEvent = function(event, inEvent) {
var eventCopy = {}, p;
for (var i = 0, ii = ol.pointer.PointerEventHandler.CLONE_PROPS.length; i < ii; i++) {
p = ol.pointer.PointerEventHandler.CLONE_PROPS[i][0];
eventCopy[p] = event[p] || inEvent[p] || ol.pointer.PointerEventHandler.CLONE_PROPS[i][1];
for (var i = 0, ii = _ol_pointer_PointerEventHandler_.CLONE_PROPS.length; i < ii; i++) {
p = _ol_pointer_PointerEventHandler_.CLONE_PROPS[i][0];
eventCopy[p] = event[p] || inEvent[p] || _ol_pointer_PointerEventHandler_.CLONE_PROPS[i][1];
}
return eventCopy;
@@ -222,8 +222,8 @@ ol.pointer.PointerEventHandler.prototype.cloneEvent = function(event, inEvent) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.down = function(data, event) {
this.fireEvent(ol.pointer.EventType.POINTERDOWN, data, event);
_ol_pointer_PointerEventHandler_.prototype.down = function(data, event) {
this.fireEvent(_ol_pointer_EventType_.POINTERDOWN, data, event);
};
@@ -232,8 +232,8 @@ ol.pointer.PointerEventHandler.prototype.down = function(data, event) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.move = function(data, event) {
this.fireEvent(ol.pointer.EventType.POINTERMOVE, data, event);
_ol_pointer_PointerEventHandler_.prototype.move = function(data, event) {
this.fireEvent(_ol_pointer_EventType_.POINTERMOVE, data, event);
};
@@ -242,8 +242,8 @@ ol.pointer.PointerEventHandler.prototype.move = function(data, event) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.up = function(data, event) {
this.fireEvent(ol.pointer.EventType.POINTERUP, data, event);
_ol_pointer_PointerEventHandler_.prototype.up = function(data, event) {
this.fireEvent(_ol_pointer_EventType_.POINTERUP, data, event);
};
@@ -252,9 +252,9 @@ ol.pointer.PointerEventHandler.prototype.up = function(data, event) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.enter = function(data, event) {
_ol_pointer_PointerEventHandler_.prototype.enter = function(data, event) {
data.bubbles = false;
this.fireEvent(ol.pointer.EventType.POINTERENTER, data, event);
this.fireEvent(_ol_pointer_EventType_.POINTERENTER, data, event);
};
@@ -263,9 +263,9 @@ ol.pointer.PointerEventHandler.prototype.enter = function(data, event) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.leave = function(data, event) {
_ol_pointer_PointerEventHandler_.prototype.leave = function(data, event) {
data.bubbles = false;
this.fireEvent(ol.pointer.EventType.POINTERLEAVE, data, event);
this.fireEvent(_ol_pointer_EventType_.POINTERLEAVE, data, event);
};
@@ -274,9 +274,9 @@ ol.pointer.PointerEventHandler.prototype.leave = function(data, event) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.over = function(data, event) {
_ol_pointer_PointerEventHandler_.prototype.over = function(data, event) {
data.bubbles = true;
this.fireEvent(ol.pointer.EventType.POINTEROVER, data, event);
this.fireEvent(_ol_pointer_EventType_.POINTEROVER, data, event);
};
@@ -285,9 +285,9 @@ ol.pointer.PointerEventHandler.prototype.over = function(data, event) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.out = function(data, event) {
_ol_pointer_PointerEventHandler_.prototype.out = function(data, event) {
data.bubbles = true;
this.fireEvent(ol.pointer.EventType.POINTEROUT, data, event);
this.fireEvent(_ol_pointer_EventType_.POINTEROUT, data, event);
};
@@ -296,8 +296,8 @@ ol.pointer.PointerEventHandler.prototype.out = function(data, event) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.cancel = function(data, event) {
this.fireEvent(ol.pointer.EventType.POINTERCANCEL, data, event);
_ol_pointer_PointerEventHandler_.prototype.cancel = function(data, event) {
this.fireEvent(_ol_pointer_EventType_.POINTERCANCEL, data, event);
};
@@ -306,7 +306,7 @@ ol.pointer.PointerEventHandler.prototype.cancel = function(data, event) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.leaveOut = function(data, event) {
_ol_pointer_PointerEventHandler_.prototype.leaveOut = function(data, event) {
this.out(data, event);
if (!this.contains_(data.target, data.relatedTarget)) {
this.leave(data, event);
@@ -319,7 +319,7 @@ ol.pointer.PointerEventHandler.prototype.leaveOut = function(data, event) {
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.enterOver = function(data, event) {
_ol_pointer_PointerEventHandler_.prototype.enterOver = function(data, event) {
this.over(data, event);
if (!this.contains_(data.target, data.relatedTarget)) {
this.enter(data, event);
@@ -334,7 +334,7 @@ ol.pointer.PointerEventHandler.prototype.enterOver = function(data, event) {
* @return {boolean} Returns true if the container element
* contains the other element.
*/
ol.pointer.PointerEventHandler.prototype.contains_ = function(container, contained) {
_ol_pointer_PointerEventHandler_.prototype.contains_ = function(container, contained) {
if (!container || !contained) {
return false;
}
@@ -352,8 +352,8 @@ ol.pointer.PointerEventHandler.prototype.contains_ = function(container, contain
* @param {Event} event The event.
* @return {ol.pointer.PointerEvent} A PointerEvent of type `inType`.
*/
ol.pointer.PointerEventHandler.prototype.makeEvent = function(inType, data, event) {
return new ol.pointer.PointerEvent(inType, event, data);
_ol_pointer_PointerEventHandler_.prototype.makeEvent = function(inType, data, event) {
return new _ol_pointer_PointerEvent_(inType, event, data);
};
@@ -363,7 +363,7 @@ ol.pointer.PointerEventHandler.prototype.makeEvent = function(inType, data, even
* @param {Object} data Pointer event data.
* @param {Event} event The event.
*/
ol.pointer.PointerEventHandler.prototype.fireEvent = function(inType, data, event) {
_ol_pointer_PointerEventHandler_.prototype.fireEvent = function(inType, data, event) {
var e = this.makeEvent(inType, data, event);
this.dispatchEvent(e);
};
@@ -374,7 +374,7 @@ ol.pointer.PointerEventHandler.prototype.fireEvent = function(inType, data, even
* and dispatches this event.
* @param {Event} event A platform event with a target.
*/
ol.pointer.PointerEventHandler.prototype.fireNativeEvent = function(event) {
_ol_pointer_PointerEventHandler_.prototype.fireNativeEvent = function(event) {
var e = this.makeEvent(event.type, event, event);
this.dispatchEvent(e);
};
@@ -387,9 +387,9 @@ ol.pointer.PointerEventHandler.prototype.fireNativeEvent = function(event) {
* @param {Event} event The event.
* @return {ol.pointer.PointerEvent} The wrapped event.
*/
ol.pointer.PointerEventHandler.prototype.wrapMouseEvent = function(eventType, event) {
_ol_pointer_PointerEventHandler_.prototype.wrapMouseEvent = function(eventType, event) {
var pointerEvent = this.makeEvent(
eventType, ol.pointer.MouseSource.prepareEvent(event, this), event);
eventType, _ol_pointer_MouseSource_.prepareEvent(event, this), event);
return pointerEvent;
};
@@ -397,9 +397,9 @@ ol.pointer.PointerEventHandler.prototype.wrapMouseEvent = function(eventType, ev
/**
* @inheritDoc
*/
ol.pointer.PointerEventHandler.prototype.disposeInternal = function() {
_ol_pointer_PointerEventHandler_.prototype.disposeInternal = function() {
this.unregister_();
ol.events.EventTarget.prototype.disposeInternal.call(this);
_ol_events_EventTarget_.prototype.disposeInternal.call(this);
};
@@ -407,7 +407,7 @@ ol.pointer.PointerEventHandler.prototype.disposeInternal = function() {
* Properties to copy when cloning an event, with default values.
* @type {Array.<Array>}
*/
ol.pointer.PointerEventHandler.CLONE_PROPS = [
_ol_pointer_PointerEventHandler_.CLONE_PROPS = [
// MouseEvent
['bubbles', false],
['cancelable', false],
@@ -441,3 +441,4 @@ ol.pointer.PointerEventHandler.CLONE_PROPS = [
['currentTarget', null],
['which', 0]
];
export default _ol_pointer_PointerEventHandler_;

View File

@@ -1,3 +1,6 @@
/**
* @module ol/pointer/TouchSource
*/
// Based on https://github.com/Polymer/PointerEvents
// Copyright (c) 2013 The Polymer Authors. All rights reserved.
@@ -28,13 +31,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
goog.provide('ol.pointer.TouchSource');
goog.require('ol');
goog.require('ol.array');
goog.require('ol.pointer.EventSource');
goog.require('ol.pointer.MouseSource');
import _ol_ from '../index.js';
import _ol_array_ from '../array.js';
import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
import _ol_pointer_MouseSource_ from '../pointer/MouseSource.js';
/**
* @constructor
@@ -42,14 +42,14 @@ goog.require('ol.pointer.MouseSource');
* @param {ol.pointer.MouseSource} mouseSource Mouse source.
* @extends {ol.pointer.EventSource}
*/
ol.pointer.TouchSource = function(dispatcher, mouseSource) {
var _ol_pointer_TouchSource_ = function(dispatcher, mouseSource) {
var mapping = {
'touchstart': this.touchstart,
'touchmove': this.touchmove,
'touchend': this.touchend,
'touchcancel': this.touchcancel
};
ol.pointer.EventSource.call(this, dispatcher, mapping);
_ol_pointer_EventSource_.call(this, dispatcher, mapping);
/**
* @const
@@ -81,7 +81,8 @@ ol.pointer.TouchSource = function(dispatcher, mouseSource) {
*/
this.resetId_ = undefined;
};
ol.inherits(ol.pointer.TouchSource, ol.pointer.EventSource);
_ol_.inherits(_ol_pointer_TouchSource_, _ol_pointer_EventSource_);
/**
@@ -90,21 +91,21 @@ ol.inherits(ol.pointer.TouchSource, ol.pointer.EventSource);
* @const
* @type {number}
*/
ol.pointer.TouchSource.DEDUP_TIMEOUT = 2500;
_ol_pointer_TouchSource_.DEDUP_TIMEOUT = 2500;
/**
* @const
* @type {number}
*/
ol.pointer.TouchSource.CLICK_COUNT_TIMEOUT = 200;
_ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT = 200;
/**
* @const
* @type {string}
*/
ol.pointer.TouchSource.POINTER_TYPE = 'touch';
_ol_pointer_TouchSource_.POINTER_TYPE = 'touch';
/**
@@ -112,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) {
_ol_pointer_TouchSource_.prototype.isPrimaryTouch_ = function(inTouch) {
return this.firstTouchId_ === inTouch.identifier;
};
@@ -122,10 +123,10 @@ ol.pointer.TouchSource.prototype.isPrimaryTouch_ = function(inTouch) {
* @param {Touch} inTouch The in touch.
* @private
*/
ol.pointer.TouchSource.prototype.setPrimaryTouch_ = function(inTouch) {
_ol_pointer_TouchSource_.prototype.setPrimaryTouch_ = function(inTouch) {
var count = Object.keys(this.pointerMap).length;
if (count === 0 || (count === 1 &&
ol.pointer.MouseSource.POINTER_ID.toString() in this.pointerMap)) {
_ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap)) {
this.firstTouchId_ = inTouch.identifier;
this.cancelResetClickCount_();
}
@@ -136,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) {
_ol_pointer_TouchSource_.prototype.removePrimaryPointer_ = function(inPointer) {
if (inPointer.isPrimary) {
this.firstTouchId_ = undefined;
this.resetClickCount_();
@@ -147,17 +148,17 @@ ol.pointer.TouchSource.prototype.removePrimaryPointer_ = function(inPointer) {
/**
* @private
*/
ol.pointer.TouchSource.prototype.resetClickCount_ = function() {
_ol_pointer_TouchSource_.prototype.resetClickCount_ = function() {
this.resetId_ = setTimeout(
this.resetClickCountHandler_.bind(this),
ol.pointer.TouchSource.CLICK_COUNT_TIMEOUT);
_ol_pointer_TouchSource_.CLICK_COUNT_TIMEOUT);
};
/**
* @private
*/
ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() {
_ol_pointer_TouchSource_.prototype.resetClickCountHandler_ = function() {
this.clickCount_ = 0;
this.resetId_ = undefined;
};
@@ -166,7 +167,7 @@ ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() {
/**
* @private
*/
ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() {
_ol_pointer_TouchSource_.prototype.cancelResetClickCount_ = function() {
if (this.resetId_ !== undefined) {
clearTimeout(this.resetId_);
}
@@ -179,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) {
_ol_pointer_TouchSource_.prototype.touchToPointer_ = function(browserEvent, inTouch) {
var e = this.dispatcher.cloneEvent(browserEvent, inTouch);
// Spec specifies that pointerId 1 is reserved for Mouse.
// Touch identifiers can start at 0.
@@ -196,7 +197,7 @@ ol.pointer.TouchSource.prototype.touchToPointer_ = function(browserEvent, inTouc
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 = _ol_pointer_TouchSource_.POINTER_TYPE;
// make sure that the properties that are different for
// each `Touch` object are not copied from the BrowserEvent object
@@ -214,7 +215,7 @@ ol.pointer.TouchSource.prototype.touchToPointer_ = function(browserEvent, inTouc
* @param {Event} inEvent Touch event
* @param {function(Event, Object)} inFunction In function.
*/
ol.pointer.TouchSource.prototype.processTouches_ = function(inEvent, inFunction) {
_ol_pointer_TouchSource_.prototype.processTouches_ = function(inEvent, inFunction) {
var touches = Array.prototype.slice.call(
inEvent.changedTouches);
var count = touches.length;
@@ -237,7 +238,7 @@ ol.pointer.TouchSource.prototype.processTouches_ = function(inEvent, inFunction)
* @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) {
_ol_pointer_TouchSource_.prototype.findTouch_ = function(touchList, searchId) {
var l = touchList.length;
var touch;
for (var i = 0; i < l; i++) {
@@ -261,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) {
_ol_pointer_TouchSource_.prototype.vacuumTouches_ = function(inEvent) {
var touchList = inEvent.touches;
// pointerMap.getCount() should be < touchList.length here,
// as the touchstart has not been processed yet.
@@ -276,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 != _ol_pointer_MouseSource_.POINTER_ID &&
!this.findTouch_(touchList, key - 2)) {
d.push(value.out);
}
@@ -294,7 +295,7 @@ ol.pointer.TouchSource.prototype.vacuumTouches_ = function(inEvent) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.TouchSource.prototype.touchstart = function(inEvent) {
_ol_pointer_TouchSource_.prototype.touchstart = function(inEvent) {
this.vacuumTouches_(inEvent);
this.setPrimaryTouch_(inEvent.changedTouches[0]);
this.dedupSynthMouse_(inEvent);
@@ -308,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) {
_ol_pointer_TouchSource_.prototype.overDown_ = function(browserEvent, inPointer) {
this.pointerMap[inPointer.pointerId] = {
target: inPointer.target,
out: inPointer,
@@ -325,7 +326,7 @@ ol.pointer.TouchSource.prototype.overDown_ = function(browserEvent, inPointer) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.TouchSource.prototype.touchmove = function(inEvent) {
_ol_pointer_TouchSource_.prototype.touchmove = function(inEvent) {
inEvent.preventDefault();
this.processTouches_(inEvent, this.moveOverOut_);
};
@@ -336,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) {
_ol_pointer_TouchSource_.prototype.moveOverOut_ = function(browserEvent, inPointer) {
var event = inPointer;
var pointer = this.pointerMap[event.pointerId];
// a finger drifted off the screen, ignore it
@@ -372,7 +373,7 @@ ol.pointer.TouchSource.prototype.moveOverOut_ = function(browserEvent, inPointer
*
* @param {Event} inEvent The event.
*/
ol.pointer.TouchSource.prototype.touchend = function(inEvent) {
_ol_pointer_TouchSource_.prototype.touchend = function(inEvent) {
this.dedupSynthMouse_(inEvent);
this.processTouches_(inEvent, this.upOut_);
};
@@ -383,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) {
_ol_pointer_TouchSource_.prototype.upOut_ = function(browserEvent, inPointer) {
this.dispatcher.up(inPointer, browserEvent);
this.dispatcher.out(inPointer, browserEvent);
this.dispatcher.leave(inPointer, browserEvent);
@@ -397,7 +398,7 @@ ol.pointer.TouchSource.prototype.upOut_ = function(browserEvent, inPointer) {
*
* @param {Event} inEvent The in event.
*/
ol.pointer.TouchSource.prototype.touchcancel = function(inEvent) {
_ol_pointer_TouchSource_.prototype.touchcancel = function(inEvent) {
this.processTouches_(inEvent, this.cancelOut_);
};
@@ -407,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) {
_ol_pointer_TouchSource_.prototype.cancelOut_ = function(browserEvent, inPointer) {
this.dispatcher.cancel(inPointer, browserEvent);
this.dispatcher.out(inPointer, browserEvent);
this.dispatcher.leave(inPointer, browserEvent);
@@ -419,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) {
_ol_pointer_TouchSource_.prototype.cleanUpPointer_ = function(inPointer) {
delete this.pointerMap[inPointer.pointerId];
this.removePrimaryPointer_(inPointer);
};
@@ -431,7 +432,7 @@ ol.pointer.TouchSource.prototype.cleanUpPointer_ = function(inPointer) {
* @private
* @param {Event} inEvent The in event.
*/
ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) {
_ol_pointer_TouchSource_.prototype.dedupSynthMouse_ = function(inEvent) {
var lts = this.mouseSource.lastTouches;
var t = inEvent.changedTouches[0];
// only the primary finger will synth mouse events
@@ -442,7 +443,8 @@ ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) {
setTimeout(function() {
// remove touch after timeout
ol.array.remove(lts, lt);
}, ol.pointer.TouchSource.DEDUP_TIMEOUT);
_ol_array_.remove(lts, lt);
}, _ol_pointer_TouchSource_.DEDUP_TIMEOUT);
}
};
export default _ol_pointer_TouchSource_;