From 0bcc5141207a1a7dce0593217755b94c9f78af75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich-Matthias=20Sch=C3=A4fer?= Date: Wed, 2 Apr 2025 11:47:27 +0200 Subject: [PATCH] feat: add option to disable single finger drag --- src/plugins/Drag.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/Drag.ts b/src/plugins/Drag.ts index c815ce4a..bd16efd2 100644 --- a/src/plugins/Drag.ts +++ b/src/plugins/Drag.ts @@ -102,6 +102,13 @@ export interface IDragOptions * @default false */ wheelSwapAxes?: boolean; + + /** + * Disable drag on touch. + * + * @default false + */ + disableTouch?: boolean; } const DEFAULT_DRAG_OPTIONS: Required = { @@ -118,6 +125,7 @@ const DEFAULT_DRAG_OPTIONS: Required = { ignoreKeyToPressOnTouch: false, lineHeight: 20, wheelSwapAxes: false, + disableTouch: false, }; /** @@ -308,6 +316,10 @@ export class Drag extends Plugin const isMouse = event.pointerType === 'mouse'; const count = this.parent.input.count(); + if (!isMouse && this.options.disableTouch && count === 1) { + return false; + } + if (count === 1 || (count > 1 && !this.parent.plugins.get('pinch', true))) { if (!isMouse || this.mouse[event.button])