| 6 | * Returns the distance between the droppable shape and the drag operation coordinates. |
| 7 | */ |
| 8 | export const pointerDistance: CollisionDetector = (input) => { |
| 9 | const {dragOperation, droppable} = input; |
| 10 | const {position} = dragOperation; |
| 11 | |
| 12 | if (!droppable.shape) { |
| 13 | return null; |
| 14 | } |
| 15 | |
| 16 | const distance = Point.distance(droppable.shape.center, position.current); |
| 17 | const value = 1 / distance; |
| 18 | |
| 19 | return { |
| 20 | id: droppable.id, |
| 21 | value, |
| 22 | type: CollisionType.Collision, |
| 23 | priority: CollisionPriority.Normal, |
| 24 | }; |
| 25 | }; |