mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-04 14:30:29 +03:00
update useDraggableItem to allow function passing to impact drag behavior
This commit is contained in:
parent
37638ff818
commit
0c2f1952d3
1 changed files with 6 additions and 2 deletions
|
|
@ -224,7 +224,8 @@ const useDraggableItem = (
|
||||||
item: SidebarDraggable,
|
item: SidebarDraggable,
|
||||||
targetRef: RefObject<HTMLElement>,
|
targetRef: RefObject<HTMLElement>,
|
||||||
onDragging: (item?: SidebarDraggable) => void,
|
onDragging: (item?: SidebarDraggable) => void,
|
||||||
dragHandleRef?: RefObject<HTMLElement>
|
dragHandleRef?: RefObject<HTMLElement>,
|
||||||
|
onActualDragStart?: () => void
|
||||||
): boolean => {
|
): boolean => {
|
||||||
const [dragging, setDragging] = useState(false);
|
const [dragging, setDragging] = useState(false);
|
||||||
|
|
||||||
|
|
@ -241,13 +242,16 @@ const useDraggableItem = (
|
||||||
onDragStart: () => {
|
onDragStart: () => {
|
||||||
setDragging(true);
|
setDragging(true);
|
||||||
onDragging?.(item);
|
onDragging?.(item);
|
||||||
|
if (typeof onActualDragStart === 'function') {
|
||||||
|
onActualDragStart();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onDrop: () => {
|
onDrop: () => {
|
||||||
setDragging(false);
|
setDragging(false);
|
||||||
onDragging?.(undefined);
|
onDragging?.(undefined);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, [targetRef, dragHandleRef, item, onDragging]);
|
}, [targetRef, dragHandleRef, item, onDragging, onActualDragStart]);
|
||||||
|
|
||||||
return dragging;
|
return dragging;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue