From 0594104153ab38c053497a62832196bbca14d9a0 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 11 Jan 2021 17:48:33 +0100 Subject: [PATCH] Fixing long clicks with chrome/firefox --- src/app/misc/long-press.directive.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/app/misc/long-press.directive.ts b/src/app/misc/long-press.directive.ts index 692e92e7..b2e2f81a 100644 --- a/src/app/misc/long-press.directive.ts +++ b/src/app/misc/long-press.directive.ts @@ -4,7 +4,6 @@ import TouchStartEvent = JQuery.TouchStartEvent; function cancelClick(event): void { - console.log("Cancel click") event.preventDefault(); event.stopPropagation(); this.removeEventListener("click", cancelClick, true); @@ -38,25 +37,16 @@ export class LongPressDirective return; this.longPressed.emit(); this._timer = null; - // We must use the nativeElement ref and can't use a HostListener - // since Angular does not support capture phase listener. - // TODO this is used for firefox since firefox still trigger a click event - // FIXME find the best way to make it work for all, use a cancelclick like - // so or find a way to prevent the event from ever happenning. this.ref.nativeElement.addEventListener("click", cancelClick, true); }, 500); } @HostListener("touchend", ["$event"]) - @HostListener("mouseup", ["$event"]) + @HostListener("window:mouseup", ["$event"]) end(): void { - console.log("test"); - // TODO this timeout is for chrome, chrome do not output a click event so the cancelClick should be removed. - // FIXME Chrome does not trigger a touchend event ether. So this is never called. setTimeout(() => { - console.log("Timeout"); this.ref.nativeElement.removeEventListener("click", cancelClick, true); }, 50); this.cancel();