feat: add useMousePosition utility#406
Conversation
Reactive cursor position tracking in viewport coordinates and relative to an optional target element. Follows the onClickOutside pattern with start()/stop()/enabled listener control. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
@huntabyte Hi would love to see this new utility get merged. useMousePosition is a pretty common hook in react style packages. All docs match the existing style, and tests all passed (excluding timed out use-search-params tests). Thank you for your review. |

Add
useMousePosition— a reactive utility that tracks cursor position in viewport coordinates and optionally relative to a target element. Follows theonClickOutsidepattern withstart()/stop()/enabledlistener control.PR Checklist
Code is formatted and linted (
pnpm lint,pnpm format)pnpm format— all files unchanged (clean)pnpm lint— 0 errors, 0 warningsTypes pass (
pnpm check)svelte-check— 0 errors, 0 warnings across both packagesTests pass locally (
pnpm test)immediateoption (4 tests)Docs updated (content + demo)
Files Added
packages/runed/src/lib/utilities/use-mouse-position/use-mouse-position.svelte.ts— implementationpackages/runed/src/lib/utilities/use-mouse-position/index.ts— barrel exportpackages/runed/src/lib/utilities/use-mouse-position/use-mouse-position.test.svelte.ts— unit testssites/docs/src/content/utilities/use-mouse-position.md— docs pagesites/docs/src/lib/components/demos/use-mouse-position.svelte— demo componentFiles Modified
packages/runed/src/lib/utilities/index.ts— addeduse-mouse-positionexport🤖 Generated with Claude Code