@mirawision/reactive-hooks
Version:
A comprehensive collection of 50+ React hooks for state management, UI interactions, device APIs, async operations, drag & drop, audio/speech, and more. Full TypeScript support with SSR safety.
24 lines (23 loc) • 919 B
TypeScript
export interface DeviceOrientation {
alpha: number | null;
beta: number | null;
gamma: number | null;
supported: boolean;
}
/**
* A hook that provides access to the device's orientation sensors.
* Returns null values when sensors are not available or permission is not granted.
* On iOS, permission may need to be requested via DeviceOrientationEvent.requestPermission().
*
* @returns Object containing:
* - alpha: rotation around z-axis (0-360)
* - beta: front/back tilt (-180 to 180)
* - gamma: left/right tilt (-90 to 90)
* - supported: whether the device supports orientation events
*/
export declare function useDeviceOrientation(): DeviceOrientation;
/**
* Request permission for device orientation events (iOS only).
* @returns Promise that resolves to true if permission is granted, false otherwise
*/
export declare function requestDeviceOrientationPermission(): Promise<boolean>;