Conditionally deregister touchend listener
This commit is contained in:
@@ -398,12 +398,15 @@ ol.MapBrowserEventHandler.prototype.handleTouchStart_ = function(browserEvent) {
|
||||
|
||||
this.down_ = browserEvent;
|
||||
this.dragged_ = false;
|
||||
this.dragListenerKeys_ = [
|
||||
goog.events.listen(goog.global.document, goog.events.EventType.TOUCHMOVE,
|
||||
this.handleTouchMove_, false, this),
|
||||
goog.events.listen(goog.global.document, goog.events.EventType.TOUCHEND,
|
||||
this.handleTouchEnd_, false, this)
|
||||
];
|
||||
|
||||
if (goog.isNull(this.dragListenerKeys_)) {
|
||||
this.dragListenerKeys_ = [
|
||||
goog.events.listen(goog.global.document, goog.events.EventType.TOUCHMOVE,
|
||||
this.handleTouchMove_, false, this),
|
||||
goog.events.listen(goog.global.document, goog.events.EventType.TOUCHEND,
|
||||
this.handleTouchEnd_, false, this)
|
||||
];
|
||||
}
|
||||
|
||||
// FIXME check if/when this is necessary
|
||||
browserEvent.preventDefault();
|
||||
@@ -436,7 +439,10 @@ ol.MapBrowserEventHandler.prototype.handleTouchEnd_ = function(browserEvent) {
|
||||
var newEvent = new ol.MapBrowserEvent(
|
||||
ol.MapBrowserEvent.EventType.TOUCHEND, this.map_, browserEvent);
|
||||
this.dispatchEvent(newEvent);
|
||||
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
|
||||
if (browserEvent.getBrowserEvent().targetTouches.length === 0) {
|
||||
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_ = null;
|
||||
}
|
||||
if (!this.dragged_) {
|
||||
goog.asserts.assert(!goog.isNull(this.down_));
|
||||
this.emulateClick_(this.down_);
|
||||
|
||||
Reference in New Issue
Block a user