useMouseVars
Feeds cursor-coordinate CSS variables to an element, powering effects.css's .lx-spot (cursor spotlight) and .lx-tilt (3D micro-tilt).
Usage
光标跟随卡片移动光标:spotlight 跟随 + 3D 微倾斜(≤±7°)
API
useMouseVars(target: Ref<HTMLElement | null>, opts?: { tilt?: boolean; maxTilt?: number }): void
| Param | Default | Description |
|---|---|---|
| target | — | target element ref |
| opts.tilt | false | emit tilt-angle variables |
| opts.maxTilt | 7 | max tilt (degrees) |
Emitted CSS variables:
| Variable | Description |
|---|---|
--lx-mx / --lx-my | cursor position inside the element (for .lx-spot) |
--lx-rx / --lx-ry | tilt angles (with tilt: true; reset on leave) |
Behavior & boundaries: SSR-safe (binds in onMounted only); no tilt output under prefers-reduced-motion: reduce.