Skip to content

Commit

Permalink
fix: fix edgeDraggable #695
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Nov 11, 2022
1 parent 3ac47da commit 9ebfae5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
39 changes: 20 additions & 19 deletions packages/react-moveable/src/react-moveable/ables/edgeDraggable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,44 @@ export default makeAble("edgeDraggable", {
props.zoom!,
);
},
dragControlCondition(moveable: MoveableManagerInterface<DraggableProps>, e: any) {
if (!moveable.props.edgeDraggable || !e.inputEvent) {
dragCondition(moveable: MoveableManagerInterface<DraggableProps>, e: any) {
const props = moveable.props;
const target = e.inputEvent?.target;

if (!props.edgeDraggable || !target) {
return false;
}
const target = e.inputEvent.target;
return hasClass(target, prefix("direction"))

return !props.draggable
&& hasClass(target, prefix("direction"))
&& hasClass(target, prefix("edge"))
&& hasClass(target, prefix("edgeDraggable"));
},
dragControlStart(moveable: MoveableManagerInterface<DraggableProps>, e: any) {
(moveable.state as any).snapRenderInfo = {
request: e.isRequest,
snap: true,
center: true,
};
dragStart(moveable: MoveableManagerInterface<DraggableProps>, e: any) {
return Draggable.dragStart(moveable, getDraggableEvent(e));
},
dragControl(moveable: MoveableManagerInterface<DraggableProps>, e: any) {
drag(moveable: MoveableManagerInterface<DraggableProps>, e: any) {
return Draggable.drag(moveable, getDraggableEvent(e));
},
dragControlEnd(moveable: MoveableManagerInterface<DraggableProps, any>, e: any) {
dragEnd(moveable: MoveableManagerInterface<DraggableProps, any>, e: any) {
return Draggable.dragEnd(moveable, getDraggableEvent(e));
},
dragGroupControlCondition(moveable: MoveableGroupInterface<DraggableProps>, e: any) {
if (!moveable.props.edgeDraggable || !e.inputEvent) {
dragGroupCondition(moveable: MoveableGroupInterface<DraggableProps>, e: any) {
const props = moveable.props;
const target = e.inputEvent?.target;

if (!props.edgeDraggable || !target) {
return false;
}
const target = e.inputEvent.target;
return hasClass(target, prefix("direction")) && hasClass(target, prefix("line"));
return !props.draggable && hasClass(target, prefix("direction")) && hasClass(target, prefix("line"));
},
dragGroupControlStart(moveable: MoveableGroupInterface<DraggableProps>, e: any) {
dragGroupStart(moveable: MoveableGroupInterface<DraggableProps>, e: any) {
return Draggable.dragGroupStart(moveable, getDraggableEvent(e));
},
dragGroupControl(moveable: MoveableGroupInterface<DraggableProps>, e: any) {
dragGroup(moveable: MoveableGroupInterface<DraggableProps>, e: any) {
return Draggable.dragGroup(moveable, getDraggableEvent(e));
},
dragGroupControlEnd(moveable: MoveableGroupInterface<DraggableProps, any>, e: any) {
dragGroupEnd(moveable: MoveableGroupInterface<DraggableProps, any>, e: any) {
return Draggable.dragGroupEnd(moveable, getDraggableEvent(e));
},
unset(moveable: any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export function triggerAble(
return false;
}).length as any;
}

if (isEnd || isForceEnd) {
moveable.state.gestos = {};

Expand Down Expand Up @@ -164,9 +165,10 @@ export function triggerAble(
}

export function checkMoveableTarget(moveable: MoveableManagerInterface) {
const dragTarget = moveable.props.dragTarget;

return (e: { inputEvent: Event }) => {
const {
dragTarget,
} = moveable.props;
const eventTarget = e.inputEvent.target as Element;
const areaElement = moveable.areaElement;

Expand Down
9 changes: 7 additions & 2 deletions packages/react-moveable/src/react-moveable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2730,7 +2730,10 @@ export interface OnCustomDrag extends GestoTypes.Position {
parentGesto: CustomGesto;
}


/**
* @typedef
* @memberof Moveable
*/
export interface PersistRectData {
/**
* left position of the target relative to the container
Expand Down Expand Up @@ -2760,7 +2763,9 @@ export interface PersistRectData {
* The absolute transform origin
*/
origin: number[];

/**
* In the case of a group, information on children is also required.
*/
children?: PersistRectData[];
}

Expand Down

0 comments on commit 9ebfae5

Please sign in to comment.