Refactor drag control management: conditionally enable drag controls based on tool mode and ensure proper cleanup on unmount.

This commit is contained in:
Jerald-Golden-B 2025-05-10 17:56:02 +05:30
parent c0a7eebecb
commit c7f0b7f84d
1 changed files with 9 additions and 1 deletions

View File

@ -31,7 +31,15 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
const { socket } = useSocketStore();
useEffect(() => {
addDragControl(dragPointControls, currentLayerPoint, state, floorPlanGroupPoint, floorPlanGroupLine, lines, onlyFloorlines, socket);
if (toolMode === 'move') {
addDragControl(dragPointControls, currentLayerPoint, state, floorPlanGroupPoint, floorPlanGroupLine, lines, onlyFloorlines, socket);
}
return () => {
if (dragPointControls.current) {
dragPointControls.current.enabled = false;
}
};
}, [toolMode, state]);
useEffect(() => {