fn

useDeviceOrientation

v0.0.14testeddemo

Reactive DeviceOrientationEvent. Provides physical orientation of the device relative to Earth's coordinate frame.

Example

ts
const { isSupported, isAbsolute, alpha, beta, gamma } = useDeviceOrientation();

Demo

Loading demo…

Signature

ts
export function useDeviceOrientation(options: UseDeviceOrientationOptions ={ ... }

Parameters

ParameterTypeDescription
options?UseDeviceOrientationOptionsOptions

Returns

UseDeviceOrientationReturnisSupported, isAbsolute, and the alpha/beta/gamma angles
PropertyTypeDescription
isSupportedComputedRef<boolean>Whether the DeviceOrientationEvent is supported in the current environment.
isAbsoluteShallowRef<boolean>Whether the device is providing orientation data absolutely (relative to Earth's coordinate frame) rather than relative to an arbitrary frame.
alphaShallowRef<number | null>Motion of the device around the z axis, in degrees (0360), or null when unavailable.
betaShallowRef<number | null>Motion of the device around the x axis, in degrees (-180180), or null when unavailable.
gammaShallowRef<number | null>Motion of the device around the y axis, in degrees (-9090), or null when unavailable.