From 586bda2b69b914fba99616d2bb2c0a7d7b9eb015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 25 May 2021 09:56:18 +0200 Subject: [PATCH] MOBILE-3320 gestures: Check pointer hasn't moved during long press --- src/core/directives/long-press.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/directives/long-press.ts b/src/core/directives/long-press.ts index 4bc79463e..a92f19c47 100644 --- a/src/core/directives/long-press.ts +++ b/src/core/directives/long-press.ts @@ -27,6 +27,7 @@ export class CoreLongPressDirective implements OnInit, OnDestroy { element: HTMLElement; pressGesture?: Gesture; + protected moved = false; @Output() longPress = new EventEmitter(); @@ -42,8 +43,11 @@ export class CoreLongPressDirective implements OnInit, OnDestroy { this.pressGesture = GestureController.create({ el: this.element, threshold: 0, + disableScroll: true, gestureName: 'longpress', - onEnd: ev => this.longPress.emit(ev.event), + onStart: () => this.moved = false, + onMove: () => this.moved = true, + onEnd: ev => !this.moved && this.longPress.emit(ev.event), }, true); this.pressGesture.enable();