mirror of
				https://github.com/excalidraw/excalidraw.git
				synced 2025-10-31 10:54:33 +01:00 
			
		
		
		
	Allow dragging transparent elements when selected (#508)
* Allow dragging transparent elements when selected Addresses #339 * Update package.json
This commit is contained in:
		 Dvir Azulay
					Dvir Azulay
				
			
				
					committed by
					
						 Christopher Chedeau
						Christopher Chedeau
					
				
			
			
				
	
			
			
			 Christopher Chedeau
						Christopher Chedeau
					
				
			
						parent
						
							d30498a289
						
					
				
				
					commit
					a856ce06e9
				
			| @@ -8,6 +8,10 @@ import { | ||||
|   getLinePoints | ||||
| } from "./bounds"; | ||||
|  | ||||
| function isElementDraggableFromInside(element: ExcalidrawElement): boolean { | ||||
|   return element.backgroundColor !== "transparent" || element.isSelected; | ||||
| } | ||||
|  | ||||
| export function hitTest( | ||||
|   element: ExcalidrawElement, | ||||
|   x: number, | ||||
| @@ -51,7 +55,7 @@ export function hitTest( | ||||
|       ty /= t; | ||||
|     }); | ||||
|  | ||||
|     if (element.backgroundColor !== "transparent") { | ||||
|     if (isElementDraggableFromInside(element)) { | ||||
|       return ( | ||||
|         a * tx - (px - lineThreshold) >= 0 && b * ty - (py - lineThreshold) >= 0 | ||||
|       ); | ||||
| @@ -61,7 +65,7 @@ export function hitTest( | ||||
|   } else if (element.type === "rectangle") { | ||||
|     const [x1, y1, x2, y2] = getElementAbsoluteCoords(element); | ||||
|  | ||||
|     if (element.backgroundColor !== "transparent") { | ||||
|     if (isElementDraggableFromInside(element)) { | ||||
|       return ( | ||||
|         x > x1 - lineThreshold && | ||||
|         x < x2 + lineThreshold && | ||||
| @@ -94,7 +98,7 @@ export function hitTest( | ||||
|       leftY | ||||
|     ] = getDiamondPoints(element); | ||||
|  | ||||
|     if (element.backgroundColor !== "transparent") { | ||||
|     if (isElementDraggableFromInside(element)) { | ||||
|       // TODO: remove this when we normalize coordinates globally | ||||
|       if (topY > bottomY) [bottomY, topY] = [topY, bottomY]; | ||||
|       if (rightX < leftX) [leftX, rightX] = [rightX, leftX]; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user