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,
 | 
			
		||||
  targetRef: RefObject<HTMLElement>,
 | 
			
		||||
  onDragging: (item?: SidebarDraggable) => void,
 | 
			
		||||
  dragHandleRef?: RefObject<HTMLElement>
 | 
			
		||||
  dragHandleRef?: RefObject<HTMLElement>,
 | 
			
		||||
  onActualDragStart?: () => void
 | 
			
		||||
): boolean => {
 | 
			
		||||
  const [dragging, setDragging] = useState(false);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -241,13 +242,16 @@ const useDraggableItem = (
 | 
			
		|||
          onDragStart: () => {
 | 
			
		||||
            setDragging(true);
 | 
			
		||||
            onDragging?.(item);
 | 
			
		||||
            if (typeof onActualDragStart === 'function') {
 | 
			
		||||
              onActualDragStart();
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          onDrop: () => {
 | 
			
		||||
            setDragging(false);
 | 
			
		||||
            onDragging?.(undefined);
 | 
			
		||||
          },
 | 
			
		||||
        });
 | 
			
		||||
  }, [targetRef, dragHandleRef, item, onDragging]);
 | 
			
		||||
  }, [targetRef, dragHandleRef, item, onDragging, onActualDragStart]);
 | 
			
		||||
 | 
			
		||||
  return dragging;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue