MCPcopy
hub / github.com/react-grid-layout/react-grid-layout / collides

Function collides

src/core/collision.ts:19–31  ·  view source on GitHub ↗
(l1: LayoutItem, l2: LayoutItem)

Source from the content-addressed store, hash-verified

17 * @returns true if the items collide
18 */
19export function collides(l1: LayoutItem, l2: LayoutItem): boolean {
20 // Same element - can't collide with itself
21 if (l1.i === l2.i) return false;
22
23 // Check if bounding boxes don't overlap (any gap means no collision)
24 if (l1.x + l1.w <= l2.x) return false; // l1 is completely left of l2
25 if (l1.x >= l2.x + l2.w) return false; // l1 is completely right of l2
26 if (l1.y + l1.h <= l2.y) return false; // l1 is completely above l2
27 if (l1.y >= l2.y + l2.h) return false; // l1 is completely below l2
28
29 // Bounding boxes overlap
30 return true;
31}
32
33/**
34 * Find the first item in the layout that collides with the given item.

Callers 8

hasOverlapsFunction · 0.90
hasOverlapsFunction · 0.90
utils-test.jsFile · 0.90
getFirstCollisionFunction · 0.70
getAllCollisionsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…