diff --git a/src/common.ts b/src/common.ts index e8763eb..3d28dbc 100644 --- a/src/common.ts +++ b/src/common.ts @@ -17,6 +17,7 @@ import "tslib"; export class DoubleClick { clicked = false; + timer: null | number = null; constructor(private timeout = 300) { } @@ -24,9 +25,15 @@ export class DoubleClick { if (!this.clicked) { this.clicked = true; singleClick(); - setTimeout(() => { + this.timer = setTimeout(() => { this.clicked = false; }, this.timeout); + } else { + this.clicked = false; + if (this.timer) { + clearTimeout(this.timer); + this.timer = null; + } } } }