source for ms pointer events (IE10)
This commit is contained in:
+11
-21
@@ -9,10 +9,10 @@ goog.require('goog.events.BrowserEvent');
|
|||||||
goog.require('goog.events.EventTarget');
|
goog.require('goog.events.EventTarget');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
|
|
||||||
goog.require('ol.pointer.PointerEventHandler');
|
|
||||||
goog.require('ol.Coordinate');
|
goog.require('ol.Coordinate');
|
||||||
goog.require('ol.MapEvent');
|
goog.require('ol.MapEvent');
|
||||||
goog.require('ol.Pixel');
|
goog.require('ol.Pixel');
|
||||||
|
goog.require('ol.pointer.PointerEventHandler');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -121,28 +121,14 @@ ol.MapBrowserEventHandler = function(map) {
|
|||||||
*/
|
*/
|
||||||
this.pointerdownListenerKey_ = null;
|
this.pointerdownListenerKey_ = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {goog.events.BrowserEvent}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.down_ = null;
|
this.down_ = null;
|
||||||
|
|
||||||
if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) {
|
var element = this.map_.getViewport();
|
||||||
/**
|
|
||||||
* @type {goog.events.Key}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
this.ieDblclickListenerKey_ = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.pointer.PointerEventHandler}
|
* @type {ol.pointer.PointerEventHandler}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.PointerEventHandler_ = null;
|
|
||||||
|
|
||||||
var element = this.map_.getViewport();
|
|
||||||
|
|
||||||
this.pointerEventHandler_ = new ol.pointer.PointerEventHandler(element);
|
this.pointerEventHandler_ = new ol.pointer.PointerEventHandler(element);
|
||||||
this.pointerdownListenerKey_ = goog.events.listen(this.pointerEventHandler_,
|
this.pointerdownListenerKey_ = goog.events.listen(this.pointerEventHandler_,
|
||||||
ol.pointer.EventType.POINTERDOWN,
|
ol.pointer.EventType.POINTERDOWN,
|
||||||
@@ -231,16 +217,19 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(browserEvent) {
|
|||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(browserEvent) {
|
ol.MapBrowserEventHandler.prototype.handlePointerDown_ =
|
||||||
|
function(browserEvent) {
|
||||||
var newEvent = new ol.MapBrowserEvent(
|
var newEvent = new ol.MapBrowserEvent(
|
||||||
ol.MapBrowserEvent.EventType.DOWN, this.map_, browserEvent);
|
ol.MapBrowserEvent.EventType.DOWN, this.map_, browserEvent);
|
||||||
this.dispatchEvent(newEvent);
|
this.dispatchEvent(newEvent);
|
||||||
this.down_ = browserEvent;
|
this.down_ = browserEvent;
|
||||||
this.dragged_ = false;
|
this.dragged_ = false;
|
||||||
this.dragListenerKeys_ = [
|
this.dragListenerKeys_ = [
|
||||||
goog.events.listen(this.pointerEventHandler_, ol.MapBrowserEvent.EventType.POINTERMOVE,
|
goog.events.listen(this.pointerEventHandler_,
|
||||||
|
ol.MapBrowserEvent.EventType.POINTERMOVE,
|
||||||
this.handlePointerMove_, false, this),
|
this.handlePointerMove_, false, this),
|
||||||
goog.events.listen(this.pointerEventHandler_, ol.MapBrowserEvent.EventType.POINTERUP,
|
goog.events.listen(this.pointerEventHandler_,
|
||||||
|
ol.MapBrowserEvent.EventType.POINTERUP,
|
||||||
this.handlePointerUp_, false, this)
|
this.handlePointerUp_, false, this)
|
||||||
];
|
];
|
||||||
// prevent browser image dragging with the dom renderer
|
// prevent browser image dragging with the dom renderer
|
||||||
@@ -252,7 +241,8 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(browserEvent)
|
|||||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEventHandler.prototype.handlePointerMove_ = function(browserEvent) {
|
ol.MapBrowserEventHandler.prototype.handlePointerMove_ =
|
||||||
|
function(browserEvent) {
|
||||||
var newEvent;
|
var newEvent;
|
||||||
if (!this.dragged_) {
|
if (!this.dragged_) {
|
||||||
this.dragged_ = true;
|
this.dragged_ = true;
|
||||||
@@ -328,7 +318,7 @@ ol.MapBrowserEvent.EventType = {
|
|||||||
TOUCHSTART: goog.events.EventType.TOUCHSTART,
|
TOUCHSTART: goog.events.EventType.TOUCHSTART,
|
||||||
TOUCHMOVE: goog.events.EventType.TOUCHMOVE,
|
TOUCHMOVE: goog.events.EventType.TOUCHMOVE,
|
||||||
TOUCHEND: goog.events.EventType.TOUCHEND,
|
TOUCHEND: goog.events.EventType.TOUCHEND,
|
||||||
|
|
||||||
POINTERMOVE: 'pointermove',
|
POINTERMOVE: 'pointermove',
|
||||||
POINTERDOWN: 'pointerdown',
|
POINTERDOWN: 'pointerdown',
|
||||||
POINTERUP: 'pointerup',
|
POINTERUP: 'pointerup',
|
||||||
|
|||||||
@@ -0,0 +1,189 @@
|
|||||||
|
goog.provide('ol.pointer.MsSource');
|
||||||
|
|
||||||
|
goog.require('ol.pointer.EventSource');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.pointer.PointerEventHandler} dispatcher
|
||||||
|
* @constructor
|
||||||
|
* @extends {ol.pointer.EventSource}
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource = function(dispatcher) {
|
||||||
|
goog.base(this, dispatcher);
|
||||||
|
|
||||||
|
this.pointerMap = dispatcher.pointerMap;
|
||||||
|
|
||||||
|
this.HAS_BITMAP_TYPE = this.hasBitmapType();
|
||||||
|
|
||||||
|
this.events = [
|
||||||
|
'MSPointerDown',
|
||||||
|
'MSPointerMove',
|
||||||
|
'MSPointerUp',
|
||||||
|
'MSPointerOut',
|
||||||
|
'MSPointerOver',
|
||||||
|
'MSPointerCancel',
|
||||||
|
'MSGotPointerCapture',
|
||||||
|
'MSLostPointerCapture'
|
||||||
|
];
|
||||||
|
this.mapping = {
|
||||||
|
'MSPointerDown': this.msPointerDown,
|
||||||
|
'MSPointerMove': this.msPointerMove,
|
||||||
|
'MSPointerUp': this.msPointerUp,
|
||||||
|
'MSPointerOut': this.msPointerOut,
|
||||||
|
'MSPointerOver': this.msPointerOver,
|
||||||
|
'MSPointerCancel': this.msPointerCancel,
|
||||||
|
'MSGotPointerCapture': this.msGotPointerCapture,
|
||||||
|
'MSLostPointerCapture': this.msLostPointerCapture
|
||||||
|
};
|
||||||
|
|
||||||
|
this.POINTER_TYPES = [
|
||||||
|
'',
|
||||||
|
'unavailable',
|
||||||
|
'touch',
|
||||||
|
'pen',
|
||||||
|
'mouse'
|
||||||
|
];
|
||||||
|
};
|
||||||
|
goog.inherits(ol.pointer.MsSource, ol.pointer.EventSource);
|
||||||
|
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
ol.pointer.MsSource.prototype.getEvents = function() {
|
||||||
|
return this.events;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
ol.pointer.MsSource.prototype.getMapping = function() {
|
||||||
|
return this.mapping;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @suppress {missingProperties}
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.hasBitmapType = function() {
|
||||||
|
return window['MSPointerEvent'] &&
|
||||||
|
typeof window['MSPointerEvent']['MSPOINTER_TYPE_MOUSE'] === 'number';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a copy of the original event that will be used
|
||||||
|
* for the fake pointer event.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {goog.events.BrowserEvent} inEvent
|
||||||
|
* @return {Object}
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.prepareEvent_ = function(inEvent) {
|
||||||
|
var e = inEvent;
|
||||||
|
if (this.HAS_BITMAP_TYPE) {
|
||||||
|
e = this.dispatcher.cloneEvent(inEvent);
|
||||||
|
e.pointerType = this.POINTER_TYPES[inEvent.pointerType];
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the mouse from the list of active pointers.
|
||||||
|
* @param {number} pointerId
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.cleanup = function(pointerId) {
|
||||||
|
this.pointerMap.remove(pointerId);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for `msPointerDown`.
|
||||||
|
*
|
||||||
|
* @param {goog.events.BrowserEvent} inEvent
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.msPointerDown = function(inEvent) {
|
||||||
|
this.pointerMap.set(inEvent.pointerId, inEvent);
|
||||||
|
var e = this.prepareEvent_(inEvent);
|
||||||
|
this.dispatcher.down(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for `msPointerMove`.
|
||||||
|
*
|
||||||
|
* @param {goog.events.BrowserEvent} inEvent
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.msPointerMove = function(inEvent) {
|
||||||
|
var e = this.prepareEvent_(inEvent);
|
||||||
|
this.dispatcher.move(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for `msPointerUp`.
|
||||||
|
*
|
||||||
|
* @param {goog.events.BrowserEvent} inEvent
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.msPointerUp = function(inEvent) {
|
||||||
|
var e = this.prepareEvent_(inEvent);
|
||||||
|
this.dispatcher.up(e);
|
||||||
|
this.cleanup(inEvent.pointerId);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for `msPointerOut`.
|
||||||
|
*
|
||||||
|
* @param {goog.events.BrowserEvent} inEvent
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.msPointerOut = function(inEvent) {
|
||||||
|
var e = this.prepareEvent_(inEvent);
|
||||||
|
this.dispatcher.leaveOut(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for `msPointerOver`.
|
||||||
|
*
|
||||||
|
* @param {goog.events.BrowserEvent} inEvent
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.msPointerOver = function(inEvent) {
|
||||||
|
var e = this.prepareEvent_(inEvent);
|
||||||
|
this.dispatcher.enterOver(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for `msPointerCancel`.
|
||||||
|
*
|
||||||
|
* @param {goog.events.BrowserEvent} inEvent
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.msPointerCancel = function(inEvent) {
|
||||||
|
var e = this.prepareEvent_(inEvent);
|
||||||
|
this.dispatcher.cancel(e);
|
||||||
|
this.cleanup(inEvent.pointerId);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for `msLostPointerCapture`.
|
||||||
|
*
|
||||||
|
* @param {goog.events.BrowserEvent} inEvent
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.msLostPointerCapture = function(inEvent) {
|
||||||
|
var e = this.dispatcher.makeEvent('lostpointercapture', inEvent);
|
||||||
|
this.dispatcher.dispatchEvent(e);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handler for `msGotPointerCapture`.
|
||||||
|
*
|
||||||
|
* @param {goog.events.BrowserEvent} inEvent
|
||||||
|
*/
|
||||||
|
ol.pointer.MsSource.prototype.msGotPointerCapture = function(inEvent) {
|
||||||
|
var e = this.dispatcher.makeEvent('gotpointercapture', inEvent);
|
||||||
|
this.dispatcher.dispatchEvent(e);
|
||||||
|
};
|
||||||
@@ -9,7 +9,7 @@ goog.require('goog.events.EventTarget');
|
|||||||
goog.require('goog.structs.Map');
|
goog.require('goog.structs.Map');
|
||||||
|
|
||||||
goog.require('ol.pointer.MouseSource');
|
goog.require('ol.pointer.MouseSource');
|
||||||
// goog.require('ol.pointer.MsSource');
|
goog.require('ol.pointer.MsSource');
|
||||||
// goog.require('ol.pointer.NativeSource');
|
// goog.require('ol.pointer.NativeSource');
|
||||||
goog.require('ol.pointer.PointerEvent');
|
goog.require('ol.pointer.PointerEvent');
|
||||||
// goog.require('ol.pointer.TouchSource');
|
// goog.require('ol.pointer.TouchSource');
|
||||||
@@ -72,7 +72,7 @@ ol.pointer.PointerEventHandler.prototype.registerSources = function() {
|
|||||||
if (this.isPointerEnabled_()) {
|
if (this.isPointerEnabled_()) {
|
||||||
// this.registerSource('native', new ol.pointer.NativeSource(this));
|
// this.registerSource('native', new ol.pointer.NativeSource(this));
|
||||||
} else if (this.isMsPointerEnabled_()) {
|
} else if (this.isMsPointerEnabled_()) {
|
||||||
// this.registerSource('ms', new ol.pointer.MsSource(this));
|
this.registerSource('ms', new ol.pointer.MsSource(this));
|
||||||
} else {
|
} else {
|
||||||
var mouseSource = new ol.pointer.MouseSource(this);
|
var mouseSource = new ol.pointer.MouseSource(this);
|
||||||
this.registerSource('mouse', mouseSource);
|
this.registerSource('mouse', mouseSource);
|
||||||
@@ -145,12 +145,13 @@ ol.pointer.PointerEventHandler.prototype.registerSource =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @suppress {undefinedVars}
|
* @suppress {undefinedVars}
|
||||||
*/
|
*/
|
||||||
ol.pointer.PointerEventHandler.prototype.log = function(obj) {
|
ol.pointer.PointerEventHandler.prototype.log = function(obj) {
|
||||||
console.log(obj);
|
console.log(obj);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ if (ol.structs.isWeakMapUndefined()) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @this {ol.structs.WeakMap}
|
||||||
* @param {*} key
|
* @param {*} key
|
||||||
* @param {*} value
|
* @param {*} value
|
||||||
*/
|
*/
|
||||||
@@ -43,6 +44,7 @@ if (ol.structs.isWeakMapUndefined()) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @this {ol.structs.WeakMap}
|
||||||
* @param {*} key
|
* @param {*} key
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user