UNPKG

@izhann/react-cursor-fx

Version:

Interactive cursor effects for React and Next.js applications — zero runtime dependencies

23 lines (22 loc) 824 B
export interface VelocityState { /** Smoothed cursor speed in px/s */ speed: number; /** Direction of travel in degrees (0 = right, 90 = down, -90 = up) */ angle: number; /** Horizontal velocity component in px/s */ vx: number; /** Vertical velocity component in px/s */ vy: number; /** True when speed exceeds idleThreshold */ isMoving: boolean; } /** * Returns smoothed cursor velocity updated every animation frame. * Uses an exponential moving average so values don't jitter on every mouse event. * The RAF loop self-suspends after ~3s of inactivity and wakes on the next move. * * @param idleThreshold - px/s below which `isMoving` becomes false (default 50) */ export declare function useVelocityCursor({ idleThreshold }?: { idleThreshold?: number; }): VelocityState;