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