MCPcopy Create free account
hub / github.com/clauderic/dnd-kit / pointerDistance

Function pointerDistance

packages/collision/src/algorithms/pointerDistance.ts:8–25  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

6 * Returns the distance between the droppable shape and the drag operation coordinates.
7 */
8export 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};

Callers

nothing calls this directly

Calls 1

distanceMethod · 0.80

Tested by

no test coverage detected