fix(react): handle drag for nodes that are initially hidden

This commit is contained in:
moklick
2024-02-29 19:44:45 +01:00
parent f7af76e76e
commit 87d363371b

View File

@@ -31,24 +31,22 @@ export function useDrag({
const xyDrag = useRef<XYDragInstance>();
useEffect(() => {
if (nodeRef?.current) {
xyDrag.current = XYDrag({
getStoreItems: () => store.getState(),
onNodeMouseDown: (id: string) => {
handleNodeClick({
id,
store,
nodeRef,
});
},
onDragStart: () => {
setDragging(true);
},
onDragStop: () => {
setDragging(false);
},
});
}
xyDrag.current = XYDrag({
getStoreItems: () => store.getState(),
onNodeMouseDown: (id: string) => {
handleNodeClick({
id,
store,
nodeRef,
});
},
onDragStart: () => {
setDragging(true);
},
onDragStop: () => {
setDragging(false);
},
});
}, []);
useEffect(() => {