Use setTimeout without the window namespace

This commit is contained in:
ahocevar
2018-10-03 13:06:14 +02:00
parent bafb9e4a8c
commit 3397796ff2
+6 -6
View File
@@ -27,10 +27,10 @@ class MapBrowserEventHandler extends EventTarget {
this.map_ = map; this.map_ = map;
/** /**
* @type {number} * @type {any}
* @private * @private
*/ */
this.clickTimeoutId_ = 0; this.clickTimeoutId_;
/** /**
* @type {boolean} * @type {boolean}
@@ -118,17 +118,17 @@ class MapBrowserEventHandler extends EventTarget {
let newEvent = new MapBrowserPointerEvent( let newEvent = new MapBrowserPointerEvent(
MapBrowserEventType.CLICK, this.map_, pointerEvent); MapBrowserEventType.CLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent); this.dispatchEvent(newEvent);
if (this.clickTimeoutId_ !== 0) { if (this.clickTimeoutId_ !== undefined) {
// double-click // double-click
clearTimeout(this.clickTimeoutId_); clearTimeout(this.clickTimeoutId_);
this.clickTimeoutId_ = 0; this.clickTimeoutId_ = undefined;
newEvent = new MapBrowserPointerEvent( newEvent = new MapBrowserPointerEvent(
MapBrowserEventType.DBLCLICK, this.map_, pointerEvent); MapBrowserEventType.DBLCLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent); this.dispatchEvent(newEvent);
} else { } else {
// click // click
this.clickTimeoutId_ = window.setTimeout(function() { this.clickTimeoutId_ = setTimeout(function() {
this.clickTimeoutId_ = 0; this.clickTimeoutId_ = undefined;
const newEvent = new MapBrowserPointerEvent( const newEvent = new MapBrowserPointerEvent(
MapBrowserEventType.SINGLECLICK, this.map_, pointerEvent); MapBrowserEventType.SINGLECLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent); this.dispatchEvent(newEvent);