@izhann/react-cursor-fx
Version:
Interactive cursor effects for React and Next.js applications — zero runtime dependencies
19 lines (18 loc) • 730 B
TypeScript
interface UseMagneticOptions {
/** Pull strength: 0 = no pull, 1 = cursor snaps to element center */
strength?: number;
/** Distance in px at which the pull begins */
distance?: number;
}
/**
* Attaches a magnetic pull effect to an element: when the cursor comes within
* `distance` pixels of the element's center, the element shifts toward the cursor.
*
* Uses the shared mouseStore — zero React re-renders in the hot path.
*
* Usage:
* const ref = useMagnetic<HTMLButtonElement>()
* return <button ref={ref}>Hover me</button>
*/
export declare function useMagnetic<T extends HTMLElement = HTMLElement>({ strength, distance, }?: UseMagneticOptions): import("react").RefObject<T | null>;
export {};