1. The Lightweight Tooltip Challenge
Tooltips seem trivial until an interactive trigger sits near the right screen edge or top header boundary. Without collision detection, static CSS tooltips render off-screen or create unwanted horizontal scrollbars.
Heavy libraries solve this by bundling full 3D matrix math and mutation observers. I engineered `tooltip-js` (`src/position.js`) with lightweight bounding-box collision detection (`overflowOf`) that flips tooltips to their opposite side (`top <-> bottom`, `left <-> right`) when bounds are exceeded.
2. Key Features
- Sub-2KB Footprint: Zero external dependencies, clean ES module output.
- Viewport Collision Flipping & Shifting: Keeps tooltips visible inside container boundaries automatically.
- ARIA Accessible Triggers: Connects `aria-describedby` dynamically on hover and keyboard focus (`Tab`).
- Declarative HTML API: Supports `data-tooltip="Text"` auto-initialization across entire document DOM trees.
3. Open Source Repository
Check out tooltip-js on GitHub: github.com/Modracx/tooltip-js.