Fix the root cause of the IE mouseup event bug.
When the event object is reference outside the call stack of the original event handler (like in a setTimeout), accessing its properties results in a "member not found" error. The solution is to clone the event object and use the clone.
This commit is contained in:
@@ -531,7 +531,7 @@ ol.Map.prototype.freezeRendering = function() {
|
||||
|
||||
/**
|
||||
* Returns the geographical coordinate for a browser event.
|
||||
* @param {Event|goog.events.BrowserEvent} event Event.
|
||||
* @param {Event} event Event.
|
||||
* @return {ol.Coordinate} Coordinate.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
@@ -542,7 +542,7 @@ ol.Map.prototype.getEventCoordinate = function(event) {
|
||||
|
||||
/**
|
||||
* Returns the map pixel position for a browser event.
|
||||
* @param {Event|goog.events.BrowserEvent} event Event.
|
||||
* @param {Event} event Event.
|
||||
* @return {ol.Pixel} Pixel.
|
||||
* @todo stability experimental
|
||||
*/
|
||||
|
||||
@@ -132,6 +132,12 @@ ol.MapBrowserEventHandler = function(map) {
|
||||
*/
|
||||
this.touchstartListenerKey_ = null;
|
||||
|
||||
/**
|
||||
* @type {goog.events.Key}
|
||||
* @private
|
||||
*/
|
||||
this.ieDblclickListenerKey_ = null;
|
||||
|
||||
/**
|
||||
* @type {goog.events.BrowserEvent}
|
||||
* @private
|
||||
@@ -161,6 +167,11 @@ ol.MapBrowserEventHandler = function(map) {
|
||||
goog.events.EventType.TOUCHSTART,
|
||||
this.handleTouchStart_, false, this);
|
||||
|
||||
if (goog.userAgent.IE && !goog.userAgent.isVersionOrHigher('9.0')) {
|
||||
this.ieDblclickListenerKey_ = goog.events.listen(element,
|
||||
goog.events.EventType.DBLCLICK,
|
||||
this.emulateClick_, false, this);
|
||||
}
|
||||
};
|
||||
goog.inherits(ol.MapBrowserEventHandler, goog.events.EventTarget);
|
||||
|
||||
@@ -190,10 +201,17 @@ ol.MapBrowserEventHandler.prototype.emulateClick_ = function(browserEvent) {
|
||||
this.dispatchEvent(newEvent);
|
||||
} else {
|
||||
// click
|
||||
|
||||
// In IE 7-8, referring to the original event object after the current
|
||||
// call stack causes "member not found" exceptions, such as in the timeout
|
||||
// we use here.
|
||||
var ev = /** @type {Event} */ (
|
||||
goog.object.clone(browserEvent.getBrowserEvent()));
|
||||
this.clickTimeoutId_ = goog.global.setTimeout(goog.bind(function() {
|
||||
this.clickTimeoutId_ = 0;
|
||||
var newEvent = new ol.MapBrowserEvent(
|
||||
ol.MapBrowserEvent.EventType.SINGLECLICK, this.map_, browserEvent);
|
||||
ol.MapBrowserEvent.EventType.SINGLECLICK, this.map_,
|
||||
new goog.events.BrowserEvent(ev, browserEvent.currentTarget));
|
||||
this.dispatchEvent(newEvent);
|
||||
}, this), 250);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user