From a1f9302754eded799e5eda4dfdd01f2983a54695 Mon Sep 17 00:00:00 2001 From: katspaugh <381895+katspaugh@users.noreply.github.com> Date: Sat, 23 Dec 2023 09:08:29 +0100 Subject: [PATCH] Feat: [Regions] pass sensitivity threshold to enableDragSelection (#3437) --- src/draggable.ts | 5 +++-- src/plugins/regions.ts | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/draggable.ts b/src/draggable.ts index 5fd93f6ca..d618a83df 100644 --- a/src/draggable.ts +++ b/src/draggable.ts @@ -28,8 +28,6 @@ export function makeDraggable( const y = event.clientY const dx = x - startX const dy = y - startY - startX = x - startY = y if (isDragging || Math.abs(dx) > threshold || Math.abs(dy) > threshold) { const rect = element.getBoundingClientRect() @@ -41,6 +39,9 @@ export function makeDraggable( } onDrag(dx, dy, x - left, y - top) + + startX = x + startY = y } } diff --git a/src/plugins/regions.ts b/src/plugins/regions.ts index b94bd9b71..26f3a2477 100644 --- a/src/plugins/regions.ts +++ b/src/plugins/regions.ts @@ -535,7 +535,7 @@ class RegionsPlugin extends BasePlugin): () => void { + public enableDragSelection(options: Omit, threshold = 3): () => void { const wrapper = this.wavesurfer?.getWrapper() if (!wrapper || !(wrapper instanceof HTMLElement)) return () => undefined @@ -588,6 +588,8 @@ class RegionsPlugin extends BasePlugin