Use setTimeout without the window namespace

This commit is contained in:
ahocevar
2018-10-03 13:06:14 +02:00
parent bafb9e4a8c
commit 3397796ff2

View File

@@ -27,10 +27,10 @@ class MapBrowserEventHandler extends EventTarget {
this.map_ = map;
/**
* @type {number}
* @type {any}
* @private
*/
this.clickTimeoutId_ = 0;
this.clickTimeoutId_;
/**
* @type {boolean}
@@ -118,17 +118,17 @@ class MapBrowserEventHandler extends EventTarget {
let newEvent = new MapBrowserPointerEvent(
MapBrowserEventType.CLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
if (this.clickTimeoutId_ !== 0) {
if (this.clickTimeoutId_ !== undefined) {
// double-click
clearTimeout(this.clickTimeoutId_);
this.clickTimeoutId_ = 0;
this.clickTimeoutId_ = undefined;
newEvent = new MapBrowserPointerEvent(
MapBrowserEventType.DBLCLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
} else {
// click
this.clickTimeoutId_ = window.setTimeout(function() {
this.clickTimeoutId_ = 0;
this.clickTimeoutId_ = setTimeout(function() {
this.clickTimeoutId_ = undefined;
const newEvent = new MapBrowserPointerEvent(
MapBrowserEventType.SINGLECLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent);