fix(react): handle drag for nodes that are initially hidden
This commit is contained in:
@@ -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(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user