From 2a90842e4ff937af6b39bbc4e147a7a7acbb0acf Mon Sep 17 00:00:00 2001 From: Daybrush Date: Fri, 19 Aug 2022 03:08:05 +0900 Subject: [PATCH] fix: stop event if no use ables #724 --- .../src/react-moveable/gesto/getAbleGesto.ts | 7 ++----- packages/react-moveable/src/react-moveable/types.ts | 3 +++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-moveable/src/react-moveable/gesto/getAbleGesto.ts b/packages/react-moveable/src/react-moveable/gesto/getAbleGesto.ts index a38166246..4638d8052 100644 --- a/packages/react-moveable/src/react-moveable/gesto/getAbleGesto.ts +++ b/packages/react-moveable/src/react-moveable/gesto/getAbleGesto.ts @@ -51,7 +51,7 @@ export function triggerAble( ables.push(...moveable.props.ables!.filter(able => able.name === requestAble)); } } - if (!ables.length) { + if (!ables.length || ables.every(able => able.dragRelation)) { return false; } const eventAbles: Able[] = [BeforeRenderable, ...ables, Renderable].filter((able: any) => able[eventName]); @@ -115,9 +115,6 @@ export function triggerAble( if (nextDatas.isEventStart) { if (able.dragRelation === "strong") { - // cancel drag - nextDatas.isEventStart = false; - return false; } // start drag @@ -125,7 +122,7 @@ export function triggerAble( } // cancel event return false; - }).length === 0; + }).length as any; } if (isEnd || isForceEnd) { moveable.state.gestos = {}; diff --git a/packages/react-moveable/src/react-moveable/types.ts b/packages/react-moveable/src/react-moveable/types.ts index 59e4395be..b0f0939f0 100644 --- a/packages/react-moveable/src/react-moveable/types.ts +++ b/packages/react-moveable/src/react-moveable/types.ts @@ -422,6 +422,9 @@ export interface Able = IObject, Events extends updateRect?: boolean; canPinch?: boolean; css?: string[]; + /** + * Check how related to drag + */ dragRelation?: "strong" | "weak" | undefined | null | false, /** * Fired when the event is cleared