no more box offset
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Deploy to Cloudflare Pages / deploy (push) Successful in 29s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Deploy to Cloudflare Pages / deploy (push) Successful in 29s
				
			This commit is contained in:
		
							parent
							
								
									df3a23a74a
								
							
						
					
					
						commit
						dc5247c4db
					
				@ -34,13 +34,12 @@ const DraggableBox = ({
 | 
			
		||||
 | 
			
		||||
      const parent = dragRef.current.parentElement;
 | 
			
		||||
      const parentRect = parent.getBoundingClientRect();
 | 
			
		||||
      const boxRect = dragRef.current.getBoundingClientRect();
 | 
			
		||||
 | 
			
		||||
      const relativeX = e.clientX - parentRect.left - dragOffset.x;
 | 
			
		||||
      const relativeY = e.clientY - parentRect.top - dragOffset.y;
 | 
			
		||||
 | 
			
		||||
      const maxX = parentRect.width - boxRect.width;
 | 
			
		||||
      const maxY = parentRect.height - boxRect.height;
 | 
			
		||||
      const maxX = parentRect.width;
 | 
			
		||||
      const maxY = parentRect.height;
 | 
			
		||||
 | 
			
		||||
      let newX = (Math.max(0, Math.min(relativeX, maxX)));
 | 
			
		||||
      let newY = (Math.max(0, Math.min(relativeY, maxY)));
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user