@supunlakmal/hooks
Version:
A collection of reusable React hooks
27 lines (26 loc) • 861 B
TypeScript
/**
* Represents the vibration pattern.
* Can be a single duration, or an array of durations and pauses.
* @see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate
*/
type VibrationPattern = number | number[];
interface UseVibrationReturn {
/** Indicates if the Vibration API is supported by the browser. */
isSupported: boolean;
/**
* Triggers vibration on the device.
* @param pattern The vibration pattern (duration or array of durations/pauses).
*/
vibrate: (pattern: VibrationPattern) => void;
/**
* Cancels any ongoing vibration pattern.
*/
cancelVibration: () => void;
}
/**
* Custom hook to interact with the browser's Vibration API.
*
* @returns An object containing vibration controls and support status.
*/
export declare function useVibration(): UseVibrationReturn;
export {};