CollisionDetector

Primitive #19

🔍 Problem it solves

An overlay might overflow the viewport – for example, a dropdown near the bottom of the screen will extend below the visible area, causing a bad user experience. You need to detect how many pixels overflow each edge.

✅ Solution

The `detectCollision(top, left, width, height)` function returns an object with `top`, `bottom`, `left`, `right` properties containing the overflow amount (in pixels) for each edge. `hasCollision()` tells you if any overflow exists.

🧩 Used by components

Tooltip, Popover, Dropdown, ContextMenu, Select, Combobox

🎮 Interactive demo