fn
useDeviceOrientation
v0.0.14testeddemoReactive 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
| Parameter | Type | Description |
|---|---|---|
options? | UseDeviceOrientationOptions | Options |
Returns
UseDeviceOrientationReturnisSupported, isAbsolute, and the alpha/beta/gamma angles| Property | Type | Description |
|---|---|---|
isSupported | ComputedRef<boolean> | Whether the DeviceOrientationEvent is supported in the current environment. |
isAbsolute | ShallowRef<boolean> | Whether the device is providing orientation data absolutely (relative to Earth's coordinate frame) rather than relative to an arbitrary frame. |
alpha | ShallowRef<number | null> | Motion of the device around the z axis, in degrees (0–360), or null
when unavailable. |
beta | ShallowRef<number | null> | Motion of the device around the x axis, in degrees (-180–180), or null
when unavailable. |
gamma | ShallowRef<number | null> | Motion of the device around the y axis, in degrees (-90–90), or null
when unavailable. |