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