Skip to content

Commit

Permalink
fix: stop event if no use ables #724
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Aug 18, 2022
1 parent 167d277 commit 2a90842
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -115,17 +115,14 @@ export function triggerAble(

if (nextDatas.isEventStart) {
if (able.dragRelation === "strong") {
// cancel drag
nextDatas.isEventStart = false;

return false;
}
// start drag
return true;
}
// cancel event
return false;
}).length === 0;
}).length as any;
}
if (isEnd || isForceEnd) {
moveable.state.gestos = {};
Expand Down
3 changes: 3 additions & 0 deletions packages/react-moveable/src/react-moveable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ export interface Able<Props extends IObject<any> = IObject<any>, 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
Expand Down

0 comments on commit 2a90842

Please sign in to comment.